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

Add linear backoff for http handlers #32

Merged
merged 2 commits into from
Mar 27, 2018
Merged

Conversation

pisarukv
Copy link
Contributor

#31

handlers/http.go Outdated
}

attempt ++
time.Sleep(handler.backoff.Next(attempt))
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like strange that it waits for 2*interval after it fails the first time. Also it may not be necessary to increase the wait time based on the attempts. Please just make it wait for interval every time before trying again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi. Thanks for the comment. I have fix the problem with attempt incrementation before wait. Also I have added Constant backoff(waiting the same interval before attempts) and made it by default. I didn't remove Linear backoff, I think in some cases it can be useful, so now user can specify backoff strategy in options.

@shuoyenl shuoyenl merged commit fd4f907 into d3sw:master Mar 27, 2018
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.

2 participants