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

feat(request): optionally retry all network failures #280

Closed
wants to merge 1 commit into from

Conversation

nbrustein
Copy link
Contributor

If Stripe. max_retries_on_network_failure is set to a value greater than 0, then any request that fails on a connection error will be retried (with the exception of RestClient::SSLCertificateNotVerified).

If the retry succeeds, then the response will be returned just as if it succeeded on the first try. If the request still fails after Stripe. max_retries_on_network_failure attempts, then the last error will be raised.

Since it is not safe to retry posts with out an idempotency_key, this code also ensures that there is always an idempotency_key if max_retries_on_network_failure is greater than 0.

@nbrustein nbrustein force-pushed the retry-network-failures branch from 3976bb1 to e497dc9 Compare August 7, 2015 18:00
@nbrustein nbrustein force-pushed the retry-network-failures branch from e497dc9 to 3b58964 Compare August 7, 2015 18:12
@kyleconroy
Copy link
Contributor

@nbrustein Thanks for the PR. Right now, we're not ready to add official retry support to the bindings. We are, however, thinking about the best way to add this in the future. Stay tuned!

@kyleconroy kyleconroy closed this Aug 7, 2015
@nbrustein
Copy link
Contributor Author

Could you tell me if there's anything special I would need to look out for if I was gonna start using something like this now? Any reason this approach would not work or be unsafe?

@booleanbetrayal
Copy link

Would love to see this or a similar mechanism in place soon!

@kyleconroy
Copy link
Contributor

@nbrustein Nope, nothing inherently wrong with your approach. To prevent tight loops, you should put in exponential backoff when retrying requests.

@nbrustein
Copy link
Contributor Author

@kyleconroy I just wanted to come back and hassle you one more time about pulling this in. We're trying to update our stripe gem today, and we have to deal with the fact that we have this special retry logic that we have to make sure isn't conflicting with any other changes.

I don't really understand your explanation for rejecting it. It sounds like you're saying "we think this is a good feature, but we'd rather write it ourselves instead of having someone else do it for us."

I don't mean to be annoying. I know that it's work for you guys to look more closely at this and decide whether to pull it in, but it's good functionality that would be useful to all of your users. It's done and it works. We've tested it in production for a couple months.

If I put in the exponential backoff would you merge it into master?

@kyleconroy
Copy link
Contributor

There is still quite a bit of work to be done with this patch before we can merge in into master. A few things off the top of my head:

  • rebase on master and ensure all tests pass (current patch fails)
  • add exponential backoff instead of retrying in a tight loop
  • only add idempotency tokens for POST requests (as DELETE and GET requests are already idempotent)
  • document the retry behavior in the README

We'll also need to take a pass over the proposed interface and make sure it's something we're comfortable committing to.

@nbrustein
Copy link
Contributor Author

@kyleconroy Thanks for your suggestions. I've resubmitted this as a new PR: #353

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 this pull request may close these issues.

3 participants