FamilySearch / gedcomx-php

PHP SDK for GEDCOM X Processing. See the documentation at
http://familysearch.github.io/gedcomx-php/
Other
35 stars 15 forks source link

Support throttling #51

Closed justincy closed 9 years ago

justincy commented 9 years ago

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.

justincy commented 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".

justincy commented 9 years ago

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.

jimmyz commented 9 years ago

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

justincy commented 9 years ago

@jimmyz Thanks, that helps a lot.

justincy commented 9 years ago

Let's implement this as middleware patterned after the RedirectMiddleware. The behavior is very similar: intercept responses and sometimes issue a new request.

ghalpert commented 9 years ago

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.

justincy commented 9 years ago

@ghalpert It's in seconds. The throttling guide is wrong. I've verified it in the response headers. I've also reported the issue.

justincy commented 9 years ago

@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.

jimmyz commented 9 years ago

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.

justincy commented 9 years ago

Enable throttling in FamilySearchClient by setting the throttling option to true.