pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub backoff_multiplier: u32,
pub jitter: bool,
pub honour_retry_after: bool,
pub max_retry_after: Duration,
}Expand description
How hard to try one candidate before moving on (spec §20.7).
Fields§
§max_attempts: u32Attempts per candidate, including the first. 1 disables retries.
initial_backoff: DurationDelay before the second attempt.
max_backoff: DurationCeiling on the computed delay.
backoff_multiplier: u32Multiplier applied per additional attempt.
jitter: boolWhether to spread delays. Off by default: a fixed schedule makes a replayed turn reproduce the same timing, and the jitter that is available is derived from the request id rather than from randomness, so it stays reproducible too.
honour_retry_after: boolWhether a provider’s own Retry-After overrides the computed backoff.
max_retry_after: DurationCeiling on a honoured Retry-After, so a provider cannot park a turn.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub const DEFAULT: Self
pub const DEFAULT: Self
Three attempts, 200 ms growing by four, capped at five seconds, no
jitter, honouring Retry-After up to thirty seconds.
Sourcepub fn backoff_for(&self, attempt: AttemptNumber) -> Duration
pub fn backoff_for(&self, attempt: AttemptNumber) -> Duration
The delay before attempt number attempt of a candidate.
attempt is 1-based, so AttemptNumber::FIRST has no delay.
Sourcepub fn delay_for(
&self,
attempt: AttemptNumber,
previous: &ProviderError,
request_id: RequestId,
) -> Duration
pub fn delay_for( &self, attempt: AttemptNumber, previous: &ProviderError, request_id: RequestId, ) -> Duration
The delay to wait before attempt, given what went wrong last time.
A RetryAfter failure that carried a delay
wins over the computed backoff when
honour_retry_after is set, capped by
max_retry_after. Jitter, when enabled, is
derived from request_id so the same turn replays with the same
timing.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
impl Eq for RetryPolicy
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
impl StructuralPartialEq 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.