Closed justincy closed 9 years ago
If httpExceptions
is set to true (throw exceptions on 400 or 500 level responses) then throttling will be an exception to that behavior. The SDK will catch the error and retry a number of times and then throw a custom exception that means "We tried x many times but never received a successful response".
I don't know how to test this behavior. php-vcr needs a way to differentiate requests in order to return different responses, but all requests here will be identical.
I think throttle handling by the SDK should be configurable.
For testing for throttled responses, the Throttling Guide has been updated with a mechanism to trigger throttled responses. https://familysearch.org/developers/docs/guides/throttling
@jimmyz Thanks, that helps a lot.
Let's implement this as middleware patterned after the RedirectMiddleware. The behavior is very similar: intercept responses and sometimes issue a new request.
Is the "Retry-After" header value in milliseconds or seconds? The RFC says seconds, but the Throttling Guide at https://familysearch.org/developers/docs/guides/throttling says milliseconds.
@ghalpert It's in seconds. The throttling guide is wrong. I've verified it in the response headers. I've also reported the issue.
@jimmyz Do some keys have a special exception to bypass throttling? I can't seem to trigger throttling with a session created during the tests.
There is a whitelist of keys that bypass throttling. I'll have to check your key with Ryan.
Jimmy
From: Justin Reply-To: FamilySearch/gedcomx-php Date: Friday, October 16, 2015 at 10:23 AM To: FamilySearch/gedcomx-php Cc: Jimmy Zimmerman Subject: Re: [gedcomx-php] Support throttling (#51)
@jimmyzhttps://github.com/jimmyz Do some keys have a special exception to bypass throttling? I can't seem to trigger throttling with a session created during the tests.
— Reply to this email directly or view it on GitHubhttps://github.com/FamilySearch/gedcomx-php/issues/51#issuecomment-148759802.
Enable throttling in FamilySearchClient
by setting the throttling
option to true
.
The SDK should recognize and properly handle 429 responses. The responses include headers which tell how long to wait until the next request. That's pretty easy to handle.