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

Back off and retry whenever API rate limits are reached #10

Merged

Conversation

chrisnovakovic
Copy link
Collaborator

Atlassian applies rate limiting to Jira's REST APIs [1]. When the rate limit for a particular endpoint has been reached, Jira produces a response that is compatible with RFC 6585 section 4: the status is set to 429 Too Many Requests, and the client is expected not to reattempt the request until at least the number of seconds given by the Retry-After header have elapsed. Currently the default Client and the built-in Transports do not respect any rate limits, and exceeding them results in errors.

Use github.com/hashicorp/go-retryablehttp to implement RFC 6585 section 4 in the default Client and built-in Transports so that the API rate limits are respected. A welcome side-effect is that failed requests due to (e.g.) network problems will also be retried (up to a maximum of 4 times, go-retryablehttp's default).

[1] https://developer.atlassian.com/cloud/jira/platform/rate-limiting/

Atlassian applies rate limiting to Jira's REST APIs [1]. When the rate
limit for a particular endpoint has been reached, Jira produces a
response that is compatible with RFC 6585 section 4: the status is set
to `429 Too Many Requests`, and the client is expected not to reattempt
the request until at least the number of seconds given by the
`Retry-After` header have elapsed. Currently the default `Client` and
the built-in `Transport`s do not respect any rate limits, and exceeding
them results in errors.

Use `github.com/hashicorp/go-retryablehttp` to implement RFC 6585
section 4 in the default `Client` and built-in `Transport`s so that the
API rate limits are respected. A welcome side-effect is that failed
requests due to (e.g.) network problems will also be retried (up to a
maximum of 4 times, go-retryablehttp's default).

[1] https://developer.atlassian.com/cloud/jira/platform/rate-limiting/
Copy link
Member

@peterebden peterebden left a comment

Choose a reason for hiding this comment

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

Nice!

@chrisnovakovic chrisnovakovic merged commit b7c0ef6 into thought-machine:v1 Feb 21, 2024
6 checks passed
@chrisnovakovic chrisnovakovic deleted the request-rate-limiting branch February 21, 2024 15:26
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