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
Extend config interface to support setting retryServerErrors
#439
Conversation
3f564e7
to
dfaa6f1
Compare
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! 🎉
The client exposes a receiver method called RetryServerErrors which toggles a flag, c.retryServerErrors, that enables/disables the retry logic in the http client. This means however, you could only enable the retry logic once the client was created, meaning any failed metadata request in `NewClient()` would not be retried. We've extended the interface of the client config object to allow enabling `c.retryServerErrors` during client init `NewClient()`.
dfaa6f1
to
fe750da
Compare
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.
I don't think this does what it says in the description?
retryServerErrors
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 reviewed this PR yesterday. Looks good! Please update the description accordingly. 🌟
Updated! 👍 |
@@ -66,17 +66,21 @@ type Config struct { | |||
|
|||
// RetryLogHook is invoked each time a request is retried. | |||
RetryLogHook RetryLogHook | |||
|
|||
// RetryServerErrors enables the retry logic in the 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.
I think we should be specific about which errors are retried here and in the CHANGELOG. I think it's just 500 and 429?
Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes. |
Description
There were instances where users would experience a network failure during the metadata or
/ping
request when callingNewClient()
.This PR adds a new field
RetryServerErrors
to theConfig
object, which sets the value forc.retryServerErrors
during client initialization and has a default value offalse
. In short, the client exposes a receiver methodRetryServerErrors(bool)
which allows you to set the value ofc.retryServerErrors
which toggles the retry logic, however it requires an initialized client. This became a problem due to the network request made inNewClient()
that wouldn't be retried should it fail -- there was no way for the user to enable the retry logic before callingNewClient()
!Making it an option in the client's configuration process will circumvent this issue.