pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub strategy: BackoffStrategy,
pub jitter: JitterType,
pub backoff_multiplier: f64,
pub total_timeout: Option<Duration>,
}Expand description
Retry policy configuration
Fields§
§max_attempts: u32Maximum number of attempts (including initial attempt)
base_delay: DurationBase delay for backoff
max_delay: DurationMaximum delay between retries
strategy: BackoffStrategyBackoff strategy
jitter: JitterTypeJitter type
backoff_multiplier: f64Multiplier for exponential backoff (default: 2.0)
total_timeout: Option<Duration>Overall timeout for all retry attempts
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn exponential(base_delay: Duration, max_attempts: u32) -> Self
pub fn exponential(base_delay: Duration, max_attempts: u32) -> Self
Create a new retry policy with exponential backoff
§Arguments
base_delay- Initial delay between retriesmax_attempts- Maximum number of attempts
Sourcepub fn fixed(delay: Duration, max_attempts: u32) -> Self
pub fn fixed(delay: Duration, max_attempts: u32) -> Self
Create a retry policy with fixed delays
Sourcepub fn linear(base_delay: Duration, max_attempts: u32) -> Self
pub fn linear(base_delay: Duration, max_attempts: u32) -> Self
Create a retry policy with linear backoff
Sourcepub fn with_max_delay(self, max_delay: Duration) -> Self
pub fn with_max_delay(self, max_delay: Duration) -> Self
Set maximum delay
Sourcepub fn with_jitter(self, jitter: JitterType) -> Self
pub fn with_jitter(self, jitter: JitterType) -> Self
Set jitter type
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set total timeout
Sourcepub fn with_multiplier(self, multiplier: f64) -> Self
pub fn with_multiplier(self, multiplier: f64) -> Self
Set backoff multiplier
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
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 RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
Source§impl<'de> Deserialize<'de> for RetryPolicy
impl<'de> Deserialize<'de> for RetryPolicy
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 RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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 more