#[non_exhaustive]pub struct RetryPolicy {
pub attempts: u32,
pub base_backoff: Duration,
pub max_backoff: Duration,
pub jitter: bool,
}Expand description
A bounded retry strategy: how many attempts, the (exponential) backoff between
them, and whether to add full jitter. Used by ManagedClient to retry
is_lock_contention failures. The Default is none
(no retry) — retry is opt-in.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.attempts: u32Total attempts including the first; 1 means no retry.
base_backoff: DurationDelay before the first retry; doubles each subsequent retry (capped by
max_backoff). ZERO means retry immediately.
max_backoff: DurationUpper bound on the (pre-jitter) backoff delay. ZERO means uncapped.
jitter: boolApply full jitter — the actual delay is uniform in [0, computed] — to
avoid a thundering herd when many workers retry against one repository.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub const fn lock_contention() -> Self
pub const fn lock_contention() -> Self
A sensible default for repository lock contention: a handful of attempts with short, jittered, exponential backoff (25 ms → 500 ms).
Sourcepub fn attempts(self, attempts: u32) -> Self
pub fn attempts(self, attempts: u32) -> Self
Set the total number of attempts (clamped to at least 1).
Sourcepub fn base_backoff(self, backoff: Duration) -> Self
pub fn base_backoff(self, backoff: Duration) -> Self
Set the base backoff (the delay before the first retry).
Sourcepub fn max_backoff(self, max: Duration) -> Self
pub fn max_backoff(self, max: Duration) -> Self
Cap the (pre-jitter) backoff delay; ZERO leaves it uncapped.
Sourcepub fn with_jitter(self, jitter: bool) -> Self
pub fn with_jitter(self, jitter: bool) -> Self
Toggle full jitter on the backoff delay.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
impl Eq for RetryPolicy
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
Source§fn eq(&self, other: &RetryPolicy) -> bool
fn eq(&self, other: &RetryPolicy) -> bool
self and other values to be equal, and is used by ==.