pub struct RetryPolicy {
pub max_retries: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: bool,
}Expand description
Retry policy configuration.
Fields§
§max_retries: u32Maximum number of retries (max_attempts = max_retries + 1).
base_delay: DurationBase delay for exponential backoff.
max_delay: DurationMaximum delay cap.
multiplier: f64Backoff multiplier (default 2.0).
jitter: boolWhether to add jitter to the delay.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Aggressive retry policy: 5 retries, fast backoff.
Sourcepub fn linear(max_retries: u32, delay: Duration) -> Self
pub fn linear(max_retries: u32, delay: Duration) -> Self
Linear retry policy: fixed delay between retries.
Sourcepub fn from_max_retries(max_retries: u32) -> Self
pub fn from_max_retries(max_retries: u32) -> Self
Create a policy from a node’s max_retries value.
Sourcepub fn from_preset(name: &str) -> Option<Self>
pub fn from_preset(name: &str) -> Option<Self>
Create a named preset.
Sourcepub fn should_retry(&self, attempt: u32) -> bool
pub fn should_retry(&self, attempt: u32) -> bool
Check if another retry is allowed.
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Calculate the delay before the next retry.
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 moreAuto 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> 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