bigcommerce-api-php icon indicating copy to clipboard operation
bigcommerce-api-php copied to clipboard

Added code for handling rate limits

Open n0rtr0n opened this issue 9 years ago • 7 comments

I'm checking for status code 429 in the handleReponse() method, which indicates that the rate limit has been reached, and simply delaying and then repeating the request after the allotted time from the 'X-Retry-After' header returned in the response, up to a maximum of 3 times for now. This has been tested locally using a script that generates over 9000 getTime() requests using OAuth authentication on a development store.

n0rtr0n avatar Oct 27 '16 22:10 n0rtr0n

Coverage Status

Coverage decreased (-1.4%) to 67.764% when pulling 4e2d57af4382516023122d8db5f5928725eb8585 on nortronthered:feature/handle-api-rate-limits into 71c6d49be1d68445801f0f4acddd82e7e815086c on bigcommerce:master.

coveralls avatar Oct 27 '16 22:10 coveralls

Coverage Status

Coverage decreased (-1.4%) to 67.764% when pulling 4e2d57af4382516023122d8db5f5928725eb8585 on nortronthered:feature/handle-api-rate-limits into 71c6d49be1d68445801f0f4acddd82e7e815086c on bigcommerce:master.

coveralls avatar Oct 27 '16 22:10 coveralls

Coverage Status

Coverage decreased (-1.4%) to 67.764% when pulling 4e2d57af4382516023122d8db5f5928725eb8585 on nortronthered:feature/handle-api-rate-limits into 71c6d49be1d68445801f0f4acddd82e7e815086c on bigcommerce:master.

coveralls avatar Oct 27 '16 22:10 coveralls

@nortronthered please see our adjustments to rate limiting headers here:

https://developer.bigcommerce.com/api/#rate-limits-oauth

This may change your approach, hopefully for the better!

bookernath avatar Apr 03 '17 02:04 bookernath

I'd feel more comfortable with this if there was a setting to turn this on or off.

lord2800 avatar May 04 '17 19:05 lord2800

Why have this not merged yet?

mrself avatar Oct 03 '17 12:10 mrself

A couple of reasons:

  1. There's an outstanding comment about removing the IDE-specific ignores.
  2. There needs to be a toggle to turn this auto-retry behavior off.
  3. We've made changes to how the rate limiting headers behave, which should help improve this code.

lord2800 avatar Oct 03 '17 17:10 lord2800