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 proper rate-limit and error controls to Shipbob client class #7

Open
lullis opened this issue Oct 15, 2022 · 0 comments
Open

Add proper rate-limit and error controls to Shipbob client class #7

lullis opened this issue Oct 15, 2022 · 0 comments

Comments

@lullis
Copy link
Contributor

lullis commented Oct 15, 2022

ShipBob's API has a rate limit of 150 requests per minute in a sliding window. The current implementation tries to account for this and also tries to respect the "Retry-after" response error in case it receives a "429 Too Many Requests" error.

The current limitation of the existing implementation:

  • It retries only once in case of a 429 error.
  • The client instance is the only one running with that access token. In case you have a process that instantiates many clients, the internal request counter will not be of much use.

It would be nice to improve this implementation to make it more robust, by:

  • making the amount of retries configurable
  • adding exponential back-off (each consecutive 429 makes the client sleep twice as long)
  • adding a hard-limit to the wait time (e.g, if the client waited for a whole minute and the requests are causing 429, give up)
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 a pull request may close this issue.

1 participant