pub struct RetryPolicy { /* private fields */ }Available on crate feature
retry only.Expand description
Retries 429 Too Many Requests, 408 Request Timeout and 5xx responses, and failures to connect.
It waits as long as a Retry-After header (in seconds) asks, or else backs off exponentially from
RetryPolicy::base_delay up to RetryPolicy::max_delay. A request whose body is a stream (a streamed file
upload) cannot be sent again and is not retried.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(max_retries: usize) -> Self
pub fn new(max_retries: usize) -> Self
A policy that retries at most max_retries times (after the first attempt).
Sourcepub fn base_delay(self, delay: Duration) -> Self
pub fn base_delay(self, delay: Duration) -> Self
The first backoff delay, doubled on each retry (default 200 ms).
Sourcepub fn max_delay(self, delay: Duration) -> Self
pub fn max_delay(self, delay: Duration) -> Self
The longest backoff delay, also the cap on Retry-After (default 8 s).
Sourcepub fn max_retries(&self) -> usize
pub fn max_retries(&self) -> usize
The number of retries allowed.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
Three retries.
impl Default for RetryPolicy
Three retries.
Source§impl<B> Policy<Request<Body>, Response<B>, Box<dyn Error + Send + Sync>> for RetryPolicy
impl<B> Policy<Request<Body>, Response<B>, Box<dyn Error + Send + Sync>> for RetryPolicy
Auto Trait Implementations§
impl Forget for RetryPolicy
impl Freeze for RetryPolicy
impl Move for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more