pub struct RetryPolicy {
pub max_attempts: u32,
pub backoff: Backoff,
pub jitter: bool,
}Expand description
A complete retry policy: how many attempts, how to back off, and whether to add jitter.
Fields§
§max_attempts: u32Maximum total attempts (1 = no retries).
backoff: BackoffBackoff schedule between attempts.
jitter: boolAdd up to ±25% randomization to each delay to avoid thundering herds.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn fixed(max_attempts: u32, delay: Duration) -> Self
pub fn fixed(max_attempts: u32, delay: Duration) -> Self
max_attempts total tries with a fixed delay between them.
Sourcepub fn exponential(max_attempts: u32, base: Duration) -> Self
pub fn exponential(max_attempts: u32, base: Duration) -> Self
Exponential backoff with jitter — a sensible production default.
Sourcepub fn should_retry(&self, attempts_made: u32) -> bool
pub fn should_retry(&self, attempts_made: u32) -> bool
Whether another attempt is allowed after attempts_made have completed.
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 moreimpl Copy for RetryPolicy
Source§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