pub enum JitterStrategy {
None,
Full,
Half,
}Expand description
Jitter strategy for retry delays.
Jitter adds randomness to retry delays to prevent thundering herd problems when many executions retry simultaneously.
§Variants
None— Use the exact calculated delay (no jitter).Full— Random delay in[0, calculated_delay].Half— Random delay in[calculated_delay/2, calculated_delay].
§Example
use durable_execution_sdk::config::JitterStrategy;
let none = JitterStrategy::None;
assert_eq!(none.apply(10.0, 1), 10.0);
let full = JitterStrategy::Full;
let jittered = full.apply(10.0, 1);
assert!(jittered >= 0.0 && jittered <= 10.0);
let half = JitterStrategy::Half;
let jittered = half.apply(10.0, 1);
assert!(jittered >= 5.0 && jittered <= 10.0);Variants§
None
No jitter — use exact calculated delay.
Full
Full jitter — random delay in [0, calculated_delay].
Half
Half jitter — random delay in [calculated_delay/2, calculated_delay].
Implementations§
Source§impl JitterStrategy
impl JitterStrategy
Sourcepub fn apply(&self, delay_secs: f64, attempt: u32) -> f64
pub fn apply(&self, delay_secs: f64, attempt: u32) -> f64
Applies jitter to a delay value in seconds.
Uses a deterministic seed derived from the attempt number via blake2b hashing. This makes jitter replay-safe since the same attempt always produces the same jittered value.
§Arguments
delay_secs- The base delay in secondsattempt- The retry attempt number (used as seed for deterministic randomness)
§Returns
The jittered delay in seconds:
None: returnsdelay_secsexactlyFull: returns a value in[0, delay_secs]Half: returns a value in[delay_secs/2, delay_secs]
Trait Implementations§
Source§impl Clone for JitterStrategy
impl Clone for JitterStrategy
Source§fn clone(&self) -> JitterStrategy
fn clone(&self) -> JitterStrategy
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 JitterStrategy
impl Debug for JitterStrategy
Source§impl Default for JitterStrategy
impl Default for JitterStrategy
Source§fn default() -> JitterStrategy
fn default() -> JitterStrategy
Returns the “default value” for a type. Read more
Source§impl PartialEq for JitterStrategy
impl PartialEq for JitterStrategy
impl Copy for JitterStrategy
impl Eq for JitterStrategy
impl StructuralPartialEq for JitterStrategy
Auto Trait Implementations§
impl Freeze for JitterStrategy
impl RefUnwindSafe for JitterStrategy
impl Send for JitterStrategy
impl Sync for JitterStrategy
impl Unpin for JitterStrategy
impl UnsafeUnpin for JitterStrategy
impl UnwindSafe for JitterStrategy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.