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

Support Retry-After in ExponentialBackoffPlugin #63

Closed
hobodave opened this issue May 25, 2012 · 3 comments
Closed

Support Retry-After in ExponentialBackoffPlugin #63

hobodave opened this issue May 25, 2012 · 3 comments

Comments

@hobodave
Copy link
Contributor

I am trying to add support for HTTP 429 responses to a web service client I am developing. Specifically, I was attempting to specify my own callable $failureCodes function and checking for the header presence in the response.

However, the problem I ran into is that I have no way to handle this with the current implementation of the ExponentialBackoffPlugin. With the current design there is no way for the "should we retry" callback to "tell" the "calculateWait" callback how long to delay. The calculateWait callback can't determine that for itself either since it doesn't have access to the Response object.

The two options I see:

  • The ExponentialBackoffPlugin could natively support 429 and handle Retry-After headers (note: Retry-After is not exclusive to 429 responses)
  • Pass the Response object (if any) to the calculate wait method so that I could check the Retry-After header in my client code

I don't have a problem implementing either: the latter is much simpler, but the former seems like it may be a more robust approach (less client code, and potentially useful to many) albeit greater in scope. Please let me know your thoughts.

@mtdowling
Copy link
Member

Passing the response to the method sounds like a good idea. I won't be able to get to this for a few days, so a PR would be awesome :)

On May 25, 2012, at 2:50 PM, David Abdemoulaiereply@reply.github.com wrote:

I am trying to add support for HTTP 429 responses to a web service client I am developing. Specifically, I was attempting to specify my own callable $failureCodes function and checking for the header presence in the response.

However, the problem I ran into is that I have no way to handle this with the current implementation of the ExponentialBackoffPlugin. With the current design there is no way for the "should we retry" callback to "tell" the "calculateWait" callback how long to delay. The calculateWait callback can't determine that for itself either since it doesn't have access to the Response object.

The two options I see:

  • The ExponentialBackoffPlugin could natively support 429 and handle Retry-After headers (note: Retry-After is not exclusive to 429 responses)
  • Pass the Response object (if any) to the calculate wait method so that I could check the Retry-After header in my client code

I don't have a problem implementing either, but the former seems like it may be a more robust approach (less client code, and potentially useful to many) albeit greater in scope. Please let me know your thoughts.


Reply to this email directly or view it on GitHub:
#63

@mtdowling
Copy link
Member

The request object is now passed to the calculateWait() function of the exponential backoff plugin. You'll need to get the response object from the request in your callback function to do any custom checks. Make sure that a response is associated with the request though. Some cURL related errors might trigger the exponential backoff plugin and a response will not be associated with the request.

@hobodave
Copy link
Contributor Author

Thanks @mtdowling ! I was too busy with the holiday weekend to do a PR; I would have this week, but you beat me to it.

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

No branches or pull requests

2 participants