pub struct RetryTransientMiddleware<T: RetryPolicy + Send + Sync + 'static> { /* private fields */ }
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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more