Struct reqwest_retry::RetryTransientMiddleware [−][src]
pub struct RetryTransientMiddleware<T: RetryPolicy + Send + Sync + 'static> { /* fields omitted */ }
Expand description
RetryTransientMiddleware
offers retry logic for requests that fail in a transient manner
and can be safely executed again.
Currently, it allows setting a RetryPolicy algorithm for calculating the wait_time between each request retry.
use reqwest_middleware::ClientBuilder; use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff}; use reqwest::Client; // We create a ExponentialBackoff retry policy which implements `RetryPolicy`. let retry_policy = ExponentialBackoff { /// How many times the policy will tell the middleware to retry the request. max_n_retries: 3, max_retry_interval: std::time::Duration::from_millis(30), min_retry_interval: std::time::Duration::from_millis(100), backoff_exponent: 2, }; let retry_transient_middleware = RetryTransientMiddleware::new_with_policy(retry_policy); let client = ClientBuilder::new(Client::new()).with(retry_transient_middleware).build();
Implementations
Construct RetryTransientMiddleware
with a retry_policy.
Trait Implementations
Invoked with a request before sending it. If you want to continue processing the request,
you should explicitly call next.run(req, extensions)
. Read more