pub struct ExponentialBackoff {
pub max_retries: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub jitter: f64,
pub multiplier: f64,
}Expand description
Exponential backoff with optional jitter.
Fields§
§max_retries: u32Maximum number of retries.
initial_delay: DurationInitial delay.
max_delay: DurationMaximum delay.
jitter: f64Jitter factor (0.0 to 1.0).
multiplier: f64Multiplier for each retry.
Implementations§
Source§impl ExponentialBackoff
impl ExponentialBackoff
Sourcepub fn new() -> ExponentialBackoff
pub fn new() -> ExponentialBackoff
Create a new exponential backoff.
Sourcepub fn builder() -> ExponentialBackoffBuilder
pub fn builder() -> ExponentialBackoffBuilder
Create a builder.
Sourcepub fn calculate_delay(&self, attempt: u32) -> Duration
pub fn calculate_delay(&self, attempt: u32) -> Duration
Calculate delay for an attempt.
Trait Implementations§
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 moreSource§impl Debug for ExponentialBackoff
impl Debug for ExponentialBackoff
Source§impl Default for ExponentialBackoff
impl Default for ExponentialBackoff
Source§fn default() -> ExponentialBackoff
fn default() -> ExponentialBackoff
Returns the “default value” for a type. Read more
Source§impl RetryStrategy for ExponentialBackoff
impl RetryStrategy for ExponentialBackoff
Source§fn should_retry(&self, error: &RetryableError, attempt: u32) -> Option<Duration>
fn should_retry(&self, error: &RetryableError, attempt: u32) -> Option<Duration>
Determine if and how long to wait before retrying. Read more
Source§fn max_retries(&self) -> u32
fn max_retries(&self) -> u32
Get the maximum number of retries.
Source§fn is_exhausted(&self, attempt: u32) -> bool
fn is_exhausted(&self, attempt: u32) -> bool
Check if retries are exhausted.
Auto 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