Skip to content
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

Merged
merged 2 commits into from
Oct 21, 2020
Merged

[Issue 257][feat] Support limit the retry number of reconnectToBroker #360

merged 2 commits into from
Oct 21, 2020

Conversation

jonyhy96
Copy link
Contributor

@jonyhy96 jonyhy96 commented Aug 25, 2020

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

  • Make sure that the change passes the CI checks.

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 changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (yes)
  • The default values of configurations: (no)
  • The wire protocol: (no)

Documentation

  • Does this pull request introduce a new feature? (yes)
  • If yes, how is the feature documented? (GoDocs)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

Signed-off-by: jonyhy96 <hy352144278@gmail.com>
@jonyhy96
Copy link
Contributor Author

/cc @wolfstudy

@wolfstudy wolfstudy added this to the 0.3.0 milestone Aug 27, 2020
@wolfstudy
Copy link
Member

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

@jonyhy96
Copy link
Contributor Author

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.
By the way,do you mean add an option at here and here,in reconnectToBroker use p.clinet.maxReconnectToBroker to decide the retry logic?

@jonyhy96
Copy link
Contributor Author

jonyhy96 commented Sep 27, 2020

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.
By the way,do you mean add an option at here and here,in reconnectToBroker use p.clinet.maxReconnectToBroker to decide the retry logic?

/cc @wolfstudy @shohi

Any further information about this? Maybe we can implement this feature before october 😄

Copy link
Member

@wolfstudy wolfstudy left a 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.

pulsar/consumer.go Show resolved Hide resolved
@jonyhy96
Copy link
Contributor Author

jonyhy96 commented Oct 9, 2020

LGTM +1, just a little comment, @jonyhy96 please help check, thanks.

Thanks for review! Already fix this.

@@ -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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, neither do I want to break the current behavior. The original commit of this pr will fulfill our request, please check out the comments above. @shohi may have different opinion on this due to his(her) proposal. Please take a review.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, agree with you

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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 <hy352144278@gmail.com>
@wolfstudy wolfstudy merged commit 44b8b4e into apache:master Oct 21, 2020
@jonyhy96 jonyhy96 deleted the feat-max-reconnect-to-broker branch October 21, 2020 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retry number limit in reconnectToBroker
3 participants