pub struct ExponentialBackoff {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: JitterStrategy,
}Expand description
Exponential backoff retry strategy.
Delays increase exponentially with each attempt: base_delay * 2^(attempt-1),
capped at max_delay. Includes optional jitter to prevent thundering herd.
§Example
use durable_execution_sdk::config::ExponentialBackoff;
use durable_execution_sdk::Duration;
// Retry up to 5 times with exponential backoff starting at 1 second
let strategy = ExponentialBackoff::new(5, Duration::from_seconds(1));
// With custom max delay
let strategy = ExponentialBackoff::builder()
.max_attempts(5)
.base_delay(Duration::from_seconds(1))
.max_delay(Duration::from_minutes(5))
.build();Fields§
§max_attempts: u32Maximum number of retry attempts (not including the initial attempt).
base_delay: DurationInitial delay before the first retry.
max_delay: DurationMaximum delay between retries.
multiplier: f64Multiplier for exponential growth (default: 2.0).
jitter: JitterStrategyJitter strategy applied to computed delays.
Implementations§
Source§impl ExponentialBackoff
impl ExponentialBackoff
Sourcepub fn new(max_attempts: u32, base_delay: Duration) -> Self
pub fn new(max_attempts: u32, base_delay: Duration) -> Self
Creates a new exponential backoff strategy with default settings.
§Arguments
max_attempts- Maximum number of retry attemptsbase_delay- Initial delay before the first retry
Sourcepub fn builder() -> ExponentialBackoffBuilder
pub fn builder() -> ExponentialBackoffBuilder
Creates a builder for more detailed configuration.
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 RetryStrategy for ExponentialBackoff
impl RetryStrategy for ExponentialBackoff
Auto Trait Implementations§
impl Freeze for ExponentialBackoff
impl RefUnwindSafe for ExponentialBackoff
impl Send for ExponentialBackoff
impl Sync for ExponentialBackoff
impl Unpin for ExponentialBackoff
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.