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

reconnect if failed #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fdingiit
Copy link

reconnect if failed

@nemith
Copy link

nemith commented Jun 18, 2021

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)
Copy link

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 {
Copy link

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.

Copy link
Author

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

Copy link
Author

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()

Copy link

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.

Copy link

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

codecov bot commented Jun 28, 2021

Codecov Report

Merging #58 (682b812) into master (ebcbcaa) will increase coverage by 0.88%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
conn.go 74.17% <100.00%> (+1.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebcbcaa...682b812. Read the comment docs.

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.

None yet

2 participants