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

adds retryablehttp client in place of standard #168

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simpixelated
Copy link

retryablehttp performs automatic retries under certain conditions

https://pkg.go.dev/github.com/hashicorp/go-retryablehttp

It's not clear to me if it will handle 429 by default, but it says this about the DefaultBackoff function:

DefaultBackoff provides a default callback for Client.Backoff which will perform exponential backoff based on the attempt number and limited by the provided minimum and maximum durations.

It also tries to parse Retry-After response header when a http.StatusTooManyRequests (HTTP Code 429) is found in the resp parameter. Hence it will return the number of seconds the server states it may be ready to process more requests from this client.

WIP: figuring out how to write tests in go to verify this is working...

@@ -128,6 +129,9 @@ func (p *segmentProvider) Configure(ctx context.Context, req provider.ConfigureR
URL: url,
},
}
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 10
configuration.HTTPClient = retryClient.StandardClient()
Copy link
Author

Choose a reason for hiding this comment

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

custom client is enabled by this in the public-api go sdk

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.

1 participant