pub struct BackoffPolicy {
pub first: Duration,
pub max: Duration,
pub factor: f64,
pub jitter: JitterPolicy,
}Expand description
Retry backoff policy.
Encapsulates parameters that determine how retry delays grow:
BackoffPolicy::factor— multiplicative growth factor;BackoffPolicy::first— the initial delay;BackoffPolicy::max— the maximum delay cap.
Fields§
§first: DurationInitial delay before the first retry.
max: DurationMaximum delay cap for retries.
factor: f64Multiplicative growth factor (>= 1.0 recommended).
jitter: JitterPolicyJitter policy to prevent thundering herd.
Implementations§
Source§impl BackoffPolicy
impl BackoffPolicy
Sourcepub fn next(&self, attempt: u32) -> Duration
pub fn next(&self, attempt: u32) -> Duration
Computes the delay for the given attempt number (0-indexed).
The base delay is first × factor^attempt, clamped to BackoffPolicy::max.
Jitter is applied to the clamped base, but the result is never fed back
into subsequent calculations — each attempt derives its base independently.
§Notes
- If
factoris less than 1.0, delays decrease with higher attempts (not typical). - If
factorequals 1.0, delay remains constant atfirst(up tomax). - If
factoris greater than 1.0, delays grow exponentially up tomax.
Trait Implementations§
Source§impl Clone for BackoffPolicy
impl Clone for BackoffPolicy
Source§fn clone(&self) -> BackoffPolicy
fn clone(&self) -> BackoffPolicy
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 BackoffPolicy
impl Debug for BackoffPolicy
Source§impl Default for BackoffPolicy
impl Default for BackoffPolicy
impl Copy for BackoffPolicy
Auto Trait Implementations§
impl Freeze for BackoffPolicy
impl RefUnwindSafe for BackoffPolicy
impl Send for BackoffPolicy
impl Sync for BackoffPolicy
impl Unpin for BackoffPolicy
impl UnsafeUnpin for BackoffPolicy
impl UnwindSafe for BackoffPolicy
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