Expand description
Middleware to retry failed HTTP requests built on reqwest_middleware
.
Use RetryTransientMiddleware
to retry failed HTTP requests. Retry control flow is managed
by a RetryPolicy
.
§Example
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};
async fn run_retries() {
// Retry up to 3 times with increasing intervals between attempts.
let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
let client = ClientBuilder::new(reqwest::Client::new())
.with(RetryTransientMiddleware::new_with_policy(retry_policy))
.build();
client
.get("https://truelayer.com")
.header("foo", "bar")
.send()
.await
.unwrap();
}
Modules§
Structs§
- The default
RetryableStrategy
forRetryTransientMiddleware
. RetryTransientMiddleware
offers retry logic for requests that fail in a transient manner and can be safely executed again.
Enums§
- How to apply jitter to the retry intervals.
- Outcome of evaluating a retry policy for a failed task.
- Custom error type to attach the number of retries to the error message.
- Classification of an error/status returned by request.
Traits§
- A policy for deciding whether and when to retry.
- A strategy to create a
Retryable
from aResult<reqwest::Response, reqwest_middleware::Error>
Functions§
- Default request failure retry strategy.
- Default request success retry strategy.