-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add retry engine #184
Add retry engine #184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really clean, few things failing but apart from that.
src/client/base/tokio.rs
Outdated
@@ -12,8 +12,6 @@ use crate::error::{ErrorResponse, StripeError}; | |||
use crate::params::{AppInfo, Headers}; | |||
use crate::resources::ApiVersion; | |||
|
|||
static USER_AGENT: &str = concat!("Stripe/v3 RustBindings/", env!("CARGO_PKG_VERSION")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this intentionally?
Missing some final issues around cloning requests. Basically cloning an http-types::Request truncates the body, so you need to re-add it. Not a tough fix but it'll have to wait for the moment! |
Codecov Report
@@ Coverage Diff @@
## master #184 +/- ##
=========================================
+ Coverage 4.34% 6.04% +1.70%
=========================================
Files 122 124 +2
Lines 10551 10624 +73
=========================================
+ Hits 458 642 +184
+ Misses 10093 9982 -111
Continue to review full report at Codecov.
|
This PR adds the ability to have the client automatically apply retries by applying a
RequestStrategy
. Closes #178There are 4 strategies:
Once
This is the basic usage (and the default). This strategy will attempt to make a request, and immediately return control to the caller when it fails.
Idempotent
This is one step up from
Once
. Using this strategy will use a idempotency key of your choice, and make requests with it. Failures will continue to return control to the caller, however you may retry the request at will.Retry (not recommended)
This strategy will make the same request up to
n
times, immediately one-after-the-other. This strategy is not recommended for production use as it is bad manners. Regardless, it may be useful for testing.Exponential Back-off
This strategy inherits all the semantics of the
Retry
strategy, but with an increasing wait between requests.Usage