pub struct ExponentialBackoff { /* private fields */ }
Expand description
Exponential backoff strategy with optional jitter
This strategy increases the delay exponentially with each attempt, and can add random jitter to prevent multiple retries from synchronizing.
Implementations§
Source§impl ExponentialBackoff
impl ExponentialBackoff
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new exponential backoff with default settings
Defaults:
- Initial delay: 100ms
- Max delay: 30000ms (30 seconds)
- Factor: 2.0 (doubles with each attempt)
- Jitter: false
Sourcepub fn with_initial_delay(self, delay_ms: u64) -> Self
pub fn with_initial_delay(self, delay_ms: u64) -> Self
Set the initial delay in milliseconds
Sourcepub fn with_max_delay(self, delay_ms: u64) -> Self
pub fn with_max_delay(self, delay_ms: u64) -> Self
Set the maximum delay in milliseconds
Sourcepub fn with_factor(self, factor: f64) -> Self
pub fn with_factor(self, factor: f64) -> Self
Set the multiplication factor for each attempt
Sourcepub fn with_jitter(self, jitter: bool) -> Self
pub fn with_jitter(self, jitter: bool) -> Self
Enable or disable jitter
Trait Implementations§
Source§impl Backoff for ExponentialBackoff
impl Backoff for ExponentialBackoff
Source§impl Clone for ExponentialBackoff
impl Clone for ExponentialBackoff
Source§fn clone(&self) -> ExponentialBackoff
fn clone(&self) -> ExponentialBackoff
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 ExponentialBackoff
impl RefUnwindSafe for ExponentialBackoff
impl Send for ExponentialBackoff
impl Sync for ExponentialBackoff
impl Unpin for ExponentialBackoff
impl UnwindSafe for ExponentialBackoff
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