pub enum BackoffStrategy {
Fixed {
base: Duration,
},
Exponential {
base: Duration,
max_delay: Duration,
},
DecorrelatedJitter {
base: Duration,
max_delay: Duration,
},
}Expand description
Backoff strategy used by RetryPolicy to compute inter-attempt delays.
| Variant | Description |
|---|---|
Fixed | Always wait the same base duration |
Exponential | base * 2^attempt (capped at max_delay) |
DecorrelatedJitter | Jittered delay in [base, prev * 3] (AWS algorithm) |
Variants§
Fixed
Return base unconditionally on every attempt.
Exponential
Double the delay on each attempt, capping at max_delay.
delay(attempt) = min(base * 2^attempt, max_delay)
Fields
Decorrelated jitter as described by AWS:
delay = random_between(base, prev_delay * 3).
RetryPolicy::next_delay uses a deterministic approximation
(base + (prev_delay * 3 - base) / 2) so that the type needs no
random-number-generator dependency. Callers that want true
randomness should implement jitter on top using the returned duration
as an upper bound.
Trait Implementations§
Source§impl Clone for BackoffStrategy
impl Clone for BackoffStrategy
Source§fn clone(&self) -> BackoffStrategy
fn clone(&self) -> BackoffStrategy
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 BackoffStrategy
impl Debug for BackoffStrategy
Source§impl<'de> Deserialize<'de> for BackoffStrategy
impl<'de> Deserialize<'de> for BackoffStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for BackoffStrategy
impl PartialEq for BackoffStrategy
Source§impl Serialize for BackoffStrategy
impl Serialize for BackoffStrategy
impl Eq for BackoffStrategy
impl StructuralPartialEq for BackoffStrategy
Auto Trait Implementations§
impl Freeze for BackoffStrategy
impl RefUnwindSafe for BackoffStrategy
impl Send for BackoffStrategy
impl Sync for BackoffStrategy
impl Unpin for BackoffStrategy
impl UnsafeUnpin for BackoffStrategy
impl UnwindSafe for BackoffStrategy
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