-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding an ability to use a default implementation for sending history. #5347
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! The approach to move save history methods into one separate interface looks really convenient.
@@ -66,10 +66,10 @@ public abstract class AbstractBolt extends BaseRichBolt { | |||
@Getter(AccessLevel.PROTECTED) | |||
private transient Integer taskId; | |||
|
|||
@Getter(AccessLevel.PROTECTED) | |||
@Getter(AccessLevel.PUBLIC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, you decided to point out explicitly AccessLevel.PUBLIC only to keep the common behaviour here, like as it is in the cases for AccessLevel.PROTECTED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a part of an interface now, so it has to be public
default String getHistoryStreamName() { | ||
return "HUB_TO_HISTORY_TOPOLOGY_SENDER"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more convenient to keep HUB_TO_HISTORY_TOPOLOGY_SENDER constant in the Stream enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have a thought that it needs to be in some place that is accessible in the bolts and the service at the same time. We need this constant when configuring topologies, so it would be convenient to have some unified approach of adding. If it is a helper method then it can't be enum that we have in the topology package.
This is a task to think about. But once it is done, we can change this method without changing the rest of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think getHistoryStreamName()
must be used in declareOutputFields
I extracted interfaces from AbstractBolt, this allows to have an interface with the default implementation for sending history. I chose it to be an interface and not a class in the hierarchy of bolts, so that we can opt-in or opt-out the default implementation more easily. Also it was needed to move classes to another module, up in the dependency structure.
I added the usage to one bolt to show how it is going to look like.
Although is solves code duplication problem, there are some downsides: