Skip to content

Add support for automatic request retries#900

Merged
ob-stripe merged 1 commit intointegration-client-refactorfrom
ob-request-retries
Nov 14, 2019
Merged

Add support for automatic request retries#900
ob-stripe merged 1 commit intointegration-client-refactorfrom
ob-request-retries

Conversation

@ob-stripe
Copy link
Contributor

r? @brandur-stripe @richardm-stripe
cc @stripe/api-libraries

After cleaning up the code, it's now pretty straightforward to add support for automatic request retries.

This PR:

  • adds a new requestWithRetries method to HttpClient
  • adds a new constructor to HttpClient to accept a maxNetworkRetries value
  • unfortunately, constructors are not inherited in Java, so I also had to add the same constructor to the concrete HttpURLConnectionClient class
  • adds a new constructor to LiveStripeResponseGetter to allow users to provide a custom HttpClient instance

This allows users to enable automatic request retries like this:

import com.stripe.net.ApiResource;
import com.stripe.net.LiveStripeResponseGetter;
import com.stripe.net.HttpURLConnectionClient;

HttpURLConnectionClient httpClient = new HttpURLConnectionClient(2);
LiveStripeResponseGetter srg = new LiveStripeResponseGetter(httpClient);
ApiResource.setStripeResponseGetter(srg);

Retries are disabled by default to match other client libraries, but we should consider enabling them by default with a reasonable max number of attempts.

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPER slick OB! Looks great. Thank you for the sleep-less test implementation as well.

@ob-stripe ob-stripe merged commit d88ff15 into integration-client-refactor Nov 14, 2019
@ob-stripe ob-stripe deleted the ob-request-retries branch November 14, 2019 17:43
ob-stripe added a commit that referenced this pull request Jan 15, 2020
* Refactor form encoding

* Refactor request telemetry

* Move HTTP request methods into new `HttpClient` class

* Add `StripeRequest` object

* Add `HttpClient` abstract class

* Stop disabling the DNS cache

* Fix deprecation warnings (#895)

* Add HttpContent class (#896)

* Add Stopwatch class (#897)

* Move all request properties in `StripeRequest` (#898)

* Remove ApiResource.RequestType (#899)

* Add support for automatic request retries (#900)

* Minor fixes (#902)

* `StringUtils` class & better API key validation (#928)

* Remove support for custom `URLStreamHandler` (#927)

* Refactor HTTP headers handling (#931)

* Add `CaseInsensitiveMap` class

* Add `HttpHeaders` class

* Use `HttpHeaders` in `StripeRequest`

* Use `HttpHeaders` in `StripeResponse`

* Address review comments

* Modernize `StripeResponse` (#932)

* Add `maxNetworkRetries` as a global and per-request setting (#934)

* Add `StreamUtils` class (#935)

* Remove support for `count` and `total_count` in list objects (#936)

* Codegen for openapi e07de1a (#938)

* Update README (#939)

Co-authored-by: remi-stripe <remi@stripe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants