pub enum RetryStrategy {
None,
Fixed {
interval: Duration,
max_attempts: u32,
},
ExponentialBackoff {
initial_delay: Duration,
multiplier: f64,
max_delay: Duration,
max_attempts: u32,
jitter: bool,
},
LinearBackoff {
initial_delay: Duration,
increment: Duration,
max_delay: Duration,
max_attempts: u32,
},
}Expand description
Retry strategy for failed jobs
Variants§
None
No retry attempts
Fixed
Fixed interval between retries
Fields
ExponentialBackoff
Exponential backoff with optional jitter
Fields
LinearBackoff
Linear backoff (delay increases linearly)
Implementations§
Source§impl RetryStrategy
impl RetryStrategy
Sourcepub fn fixed(interval: Duration, max_attempts: u32) -> Self
pub fn fixed(interval: Duration, max_attempts: u32) -> Self
Create a fixed interval retry strategy
Sourcepub fn exponential_backoff(
initial_delay: Duration,
multiplier: f64,
max_delay: Duration,
max_attempts: u32,
) -> Self
pub fn exponential_backoff( initial_delay: Duration, multiplier: f64, max_delay: Duration, max_attempts: u32, ) -> Self
Create an exponential backoff strategy
Sourcepub fn linear_backoff(
initial_delay: Duration,
increment: Duration,
max_delay: Duration,
max_attempts: u32,
) -> Self
pub fn linear_backoff( initial_delay: Duration, increment: Duration, max_delay: Duration, max_attempts: u32, ) -> Self
Create a linear backoff strategy
Sourcepub fn calculate_delay(&self, attempt: u32) -> Option<Duration>
pub fn calculate_delay(&self, attempt: u32) -> Option<Duration>
Calculate the delay for the next retry attempt
Sourcepub fn max_attempts(&self) -> u32
pub fn max_attempts(&self) -> u32
Get the maximum number of retry attempts
Sourcepub fn is_retry_enabled(&self) -> bool
pub fn is_retry_enabled(&self) -> bool
Check if retries are enabled
Trait Implementations§
Source§impl Clone for RetryStrategy
impl Clone for RetryStrategy
Source§fn clone(&self) -> RetryStrategy
fn clone(&self) -> RetryStrategy
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 RetryStrategy
impl Debug for RetryStrategy
Source§impl Default for RetryStrategy
impl Default for RetryStrategy
Source§impl<'de> Deserialize<'de> for RetryStrategy
impl<'de> Deserialize<'de> for RetryStrategy
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
Auto Trait Implementations§
impl Freeze for RetryStrategy
impl RefUnwindSafe for RetryStrategy
impl Send for RetryStrategy
impl Sync for RetryStrategy
impl Unpin for RetryStrategy
impl UnwindSafe for RetryStrategy
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