pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub jitter_factor: f64,
/* private fields */
}Expand description
Configuration for retry behavior with exponential backoff support.
Fields§
§max_attempts: u32§base_delay: Duration§max_delay: Duration§jitter_factor: f64Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn with_exponential_backoff(
max_attempts: u32,
base_delay: Duration,
max_delay: Duration,
jitter_factor: f64,
) -> Self
pub fn with_exponential_backoff( max_attempts: u32, base_delay: Duration, max_delay: Duration, jitter_factor: f64, ) -> Self
Exponential backoff retry with jitter.
Sourcepub fn with_retryable_predicate(self, predicate: fn(&str) -> bool) -> Self
pub fn with_retryable_predicate(self, predicate: fn(&str) -> bool) -> Self
Sets a predicate function to determine if an error should trigger a retry.
Sourcepub fn next_delay(&self, attempt: u32) -> Duration
pub fn next_delay(&self, attempt: u32) -> Duration
Computes the delay for a given attempt number.
This method contains self-contained exponential backoff logic
(base_delay * 2^attempt, capped at max_delay, with optional jitter).
There is a separate super::ExponentialBackoff type elsewhere in the
resilience module, but this implementation is intentionally kept inline:
RetryPolicy needs tight control over attempt numbering and jitter that
would not benefit from an extra layer of indirection.
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 (const: unstable) · 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
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin 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> 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