-
Notifications
You must be signed in to change notification settings - Fork 125
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
reconnect if failed #58
base: master
Are you sure you want to change the base?
Conversation
I am not sure this will do what you want it to do. connect() already has a retry loop inside of it and it only returns errors if c.shoudlExit is true. What issues are you running into that you think this change is needed? What testing have you done before/after the change? Can you show some test results? Unit tests would be good as well, but like i stated above I am not sure this will do what we want to to do, however perhaps there is another issue you are trying to solve? |
@@ -423,7 +423,9 @@ func (c *Conn) loop(ctx context.Context) { | |||
for { | |||
if err := c.connect(); err != nil { | |||
// c.Close() was called | |||
return | |||
c.logger.Printf("connect failed: %s", err) | |||
time.Sleep(time.Second) |
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.
This seem arbitrary? Why one second?
@@ -423,7 +423,9 @@ func (c *Conn) loop(ctx context.Context) { | |||
for { | |||
if err := c.connect(); err != nil { |
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.
connect seems to only return an error when c.shouldQuit is set. connect already has a reconnect loop as well, so I am not sure this will do what you want it to do.
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.
case: zk server startup AFTER zk client
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.
connect() failed and then RETURN loop()
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.
Could you help explain this a bit more for me. I am sure you are right, but I am not picturing the scenario.
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.
Also any unittest here would be good. The logic here is not trivial and a unittest could document the issue as well protect against regressions
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 75.77% 76.65% +0.88%
==========================================
Files 7 7
Lines 1189 1191 +2
==========================================
+ Hits 901 913 +12
+ Misses 197 190 -7
+ Partials 91 88 -3
Continue to review full report at Codecov.
|
reconnect if failed