pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: f64,
}Expand description
Typed retry policy shared across runtime layers.
Fields§
§max_attempts: u32Maximum number of total attempts, including the initial call.
initial_delay: Duration§max_delay: Duration§multiplier: f64§jitter: f64Implementations§
Source§impl RetryPolicy
impl RetryPolicy
pub fn new( max_attempts: u32, initial_delay: Duration, max_delay: Duration, multiplier: f64, ) -> Self
pub fn from_retries( max_retries: u32, initial_delay: Duration, max_delay: Duration, multiplier: f64, ) -> Self
Sourcepub fn simple(max_retries: u32, base_delay_ms: u64, max_delay_ms: u64) -> Self
pub fn simple(max_retries: u32, base_delay_ms: u64, max_delay_ms: u64) -> Self
Millisecond-based constructor for wire clients.
Uses a 2.0 multiplier and no jitter, so
Self::delay_for_attempt reproduces the classic
base_ms << attempt doubling curve capped at max_delay_ms.
pub fn delay_for_attempt(&self, attempt_index: u32) -> Duration
pub fn decision_for_category( &self, category: ErrorCategory, attempt_index: u32, retry_after: Option<Duration>, ) -> RetryDecision
Sourcepub fn classify_anyhow(&self, error: &Error) -> RetryDecision
pub fn classify_anyhow(&self, error: &Error) -> RetryDecision
Classify an anyhow::Error for retry eligibility.
Attempt-agnostic: retryable reflects only the error category, not
the remaining attempt budget. Wire clients that manage their own
attempt counting use this; loops that want budget-aware decisions
use Self::decision_for_category.
Sourcepub fn classify_status(&self, status: u16) -> RetryDecision
pub fn classify_status(&self, status: u16) -> RetryDecision
Classify an HTTP status code for retry eligibility.
Attempt-agnostic, like Self::classify_anyhow.
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
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
Source§impl<'de> Deserialize<'de> for RetryPolicy
impl<'de> Deserialize<'de> for RetryPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
Source§fn eq(&self, other: &RetryPolicy) -> bool
fn eq(&self, other: &RetryPolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for RetryPolicy
impl Serialize 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
Mutably borrows from an owned value. Read more