pub struct Retry {
pub name: &'static str,
pub attempts: u32,
pub base_delay: Duration,
pub delay_factor: f64,
pub enable_jitter: bool,
}Expand description
Calls a fallible async function multiple times, with a given timeout.
If a base_delay is provided, the function is given an exponentially
increasing delay on each run, up until the maximum number of attempts.
Returns the first successful result if any, or the last error.
Fields§
§name: &'static strName of the operation being retried.
attempts: u32The number of attempts to make.
base_delay: DurationThe base delay after the first attempt, if provided.
delay_factor: f64Exponential factor to increase the delay by on each attempt.
enable_jitter: boolIf true, the delay will be selected randomly from the range [delay/2, delay).
Implementations§
Source§impl Retry
impl Retry
Sourcepub const fn new(name: &'static str) -> Self
pub const fn new(name: &'static str) -> Self
Construct a new Retry object with default parameters.
Sourcepub const fn base_delay(self, base_delay: Duration) -> Self
pub const fn base_delay(self, base_delay: Duration) -> Self
Set the base delay.
Sourcepub const fn delay_factor(self, delay_factor: f64) -> Self
pub const fn delay_factor(self, delay_factor: f64) -> Self
Set the exponential factor increasing delay.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Retry
impl RefUnwindSafe for Retry
impl Send for Retry
impl Sync for Retry
impl Unpin for Retry
impl UnwindSafe for Retry
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