pub enum RetryPolicy {
Immediate {
current_retries: u32,
max_retries: u32,
},
ConstantDelay {
current_retries: u32,
max_retries: u32,
delay: Duration,
},
ExponentialBackoff {
current_retries: u32,
max_retries: u32,
initial_delay: Duration,
max_delay: Duration,
},
}
Expand description
A policy for configuring how requests should retry when they fail.
Variants§
Immediate
Retry the request immediately.
Fields
ConstantDelay
Retry the request after a delay.
Fields
ExponentialBackoff
Retry the request after a delay, with exponential backoff.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
pub fn max_retries(&self) -> u32
Sourcepub async fn failed_request(&mut self) -> bool
pub async fn failed_request(&mut self) -> bool
Executes a retry policy, including incrementing the retry count and delaying if necessary.
Sourcepub fn immediate(max_retries: u32) -> Self
pub fn immediate(max_retries: u32) -> Self
Returns a new retry policy that will retry immediately, with a maximum number of retries.
Sourcepub fn constant_delay(max_retries: u32, delay: Duration) -> Self
pub fn constant_delay(max_retries: u32, delay: Duration) -> Self
Returns a new retry policy that will retry after a constant delay, with a maximum number of retries.
Sourcepub fn exponential_backoff(
max_retries: u32,
initial_delay: Duration,
max_delay: Duration,
) -> Self
pub fn exponential_backoff( max_retries: u32, initial_delay: Duration, max_delay: Duration, ) -> Self
Returns a new retry policy that will retry after an exponentially increasing delay, with a maximum number of retries, and a maximum delay.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin 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