-
Notifications
You must be signed in to change notification settings - Fork 344
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
[Issue 257][feat] Support limit the retry number of reconnectToBroker #360
[Issue 257][feat] Support limit the retry number of reconnectToBroker #360
Conversation
Signed-off-by: jonyhy96 <[email protected]>
/cc @wolfstudy |
Thanks @jonyhy96 Here, I have only one confusion. When users use it, they need to set it on the producer and consumer at the same time, right? Can we consider exposing this parameter to the user in ClientOptions so that the user only needs to set it once |
That would be more convenience for users to use, But the user loses more detailed control over the program. |
/cc @wolfstudy @shohi Any further information about this? Maybe we can implement this feature before october 😄 |
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.
LGTM +1, just a little comment, @jonyhy96 please help check, thanks.
Thanks for review! Already fix this. |
pulsar/producer.go
Outdated
@@ -138,6 +138,9 @@ type ProducerOptions struct { | |||
|
|||
// A chain of interceptors, These interceptors will be called at some points defined in ProducerInterceptor interface | |||
Interceptors ProducerInterceptors | |||
|
|||
// MaxReconnectToBroker set the maximum retry number of reconnectToBroker. (default: no retry) | |||
MaxReconnectToBroker int |
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.
@jonyhy96 Can we not modify the original default behavior, and we will always retry by default. When we set the maximum number of retries, we will turn off the retry logic after reaching the specified threshold.
Because the current behavior will break the backward compatibility of the version
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.
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.
We can consider setting -1 as the default value, and then check whether MaxReconnectToBroker is set, and if so, use the user-defined value.
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.
At present, I see that you have added the option of MaxReconnectToBroker to the relevant test cases. This may not be very user-friendly. We need to ensure that the interface is as simple as possible.
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.
We can consider setting -1 as the default value, and then check whether MaxReconnectToBroker is set, and if so, use the user-defined value.
I understand,but how can we determine whether MaxReconnectToBroker is set or not when it's default value is meaningful. e.g. user set this option to 0.
At present, I see that you have added the option of MaxReconnectToBroker to the relevant test cases. This may not be very user-friendly. We need to ensure that the interface is as simple as possible.
I totally agree, how about we use the origin commit of this pr to implement this feature?
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.
ok, agree with you
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.
Should i reset this pr to original commit or keep it this way?
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.
@jonyhy96 Sorry for the reply later, i think we should reset this pull request to the original commit for backward compatibility.
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.
@jonyhy96 Sorry for the reply later, i think we should reset this pull request to the original commit for backward compatibility.
Already reset this pr to original commit.
By the way, the go.mod file seems a little bit dirty,you can reproduce this by run comamnd go mod tidy
locally.
➜ pulsar-client-go git:(feat-max-reconnect-to-broker) go mod tidy -v
unused github.com/modern-go/concurrent
unused github.com/modern-go/reflect2
perhaps add script below to ci for check if go.mod has been commit correctly
go mod tidy
git diff --exit-code -- go.mod go.sum
…t-to-broker Signed-off-by: jonyhy96 <[email protected]>
Fixes #257
Motivation
Once the connection is closed the reconnectToBroker logic of both producer and consumer will try to reconnect to the broker infinatly.
Modifications
Add a field in the Options represent the max number of retries and not break current behavior if this field is not fullfilled.
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation