pub struct RetryConfig {
pub max_attempts: usize,
pub base_delay: Duration,
pub max_delay: Duration,
pub backoff_strategy: BackoffStrategy,
pub jitter_strategy: JitterStrategy,
pub should_retry_fn: Option<RetryFn>,
}Expand description
Advanced retry configuration with adaptive strategies
Fields§
§max_attempts: usizeMaximum number of retry attempts
base_delay: DurationBase delay between retries
max_delay: DurationMaximum delay between retries (for exponential backoff)
backoff_strategy: BackoffStrategyBackoff strategy to use
jitter_strategy: JitterStrategyJitter strategy to avoid thundering herd
should_retry_fn: Option<RetryFn>Custom retry decision function (not cloneable, so we’ll skip it in Clone)
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn max_attempts(self, max_attempts: usize) -> Self
pub fn max_attempts(self, max_attempts: usize) -> Self
Set maximum retry attempts
Sourcepub fn base_delay(self, delay: Duration) -> Self
pub fn base_delay(self, delay: Duration) -> Self
Set base delay
Sourcepub fn exponential_backoff(self, multiplier: f64) -> Self
pub fn exponential_backoff(self, multiplier: f64) -> Self
Use exponential backoff strategy
Sourcepub fn fixed_backoff(self) -> Self
pub fn fixed_backoff(self) -> Self
Use fixed backoff strategy
Sourcepub fn linear_backoff(self, increment: Duration) -> Self
pub fn linear_backoff(self, increment: Duration) -> Self
Use linear backoff strategy
Sourcepub fn jitter(self, strategy: JitterStrategy) -> Self
pub fn jitter(self, strategy: JitterStrategy) -> Self
Set jitter strategy
Sourcepub fn should_retry<F>(self, f: F) -> Self
pub fn should_retry<F>(self, f: F) -> Self
Set custom retry condition
Sourcepub fn for_network_operations() -> Self
pub fn for_network_operations() -> Self
Smart defaults for different scenarios
pub fn for_rate_limited_apis() -> Self
pub fn for_quick_operations() -> Self
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Auto Trait Implementations§
impl Freeze for RetryConfig
impl !RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl !UnwindSafe for RetryConfig
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