pub struct BackoffPolicy {
pub first: Duration,
pub max: Duration,
pub factor: f64,
pub jitter: JitterPolicy,
pub success_delay: Option<Duration>,
}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.
success_delay: Option<Duration>Delay to wait after a successful attempt.
Implementations§
Source§impl BackoffPolicy
impl BackoffPolicy
Sourcepub fn next(&self, prev: Option<Duration>) -> Duration
pub fn next(&self, prev: Option<Duration>) -> Duration
Computes the next delay based on the previous one.
- If
previsNone, returnsfirstclamped tomax. - Otherwise multiplies the previous delay by
BackoffPolicy::factor, and caps it atBackoffPolicy::max.
§Notes
- If
factoris less than 1.0, delays decrease over time (not typical). - If
factorequals 1.0, delay remains constant atfirst(up tomax). - If
factoris greater than 1.0, delays grow exponentially.
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 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