pub struct RetryConfig {
pub max_retries: u32,
pub retry_delays: Vec<f64>,
pub retryable_status_codes: Vec<u16>,
pub initial_delay_ms: u64,
pub backoff_factor: f64,
pub max_delay_ms: u64,
}Expand description
Configuration for retry behavior.
Fields§
§max_retries: u32Maximum number of retry attempts (not counting the initial request).
retry_delays: Vec<f64>Base delays in seconds for exponential backoff.
retryable_status_codes: Vec<u16>HTTP status codes that trigger a retry.
initial_delay_ms: u64Initial delay in milliseconds for exponential backoff.
backoff_factor: f64Multiplier for exponential backoff (delay *= factor each attempt).
max_delay_ms: u64Maximum delay in milliseconds (cap for exponential growth).
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Get the delay for a given attempt index (0-based).
Uses exponential backoff: initial_delay_ms * backoff_factor^attempt,
capped at max_delay_ms. Falls back to the legacy retry_delays array
if initial_delay_ms is 0.
Sourcepub fn is_retryable_status(&self, status: u16) -> bool
pub fn is_retryable_status(&self, status: u16) -> bool
Check if a status code is retryable.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
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 moreSource§impl Debug for RetryConfig
impl Debug for RetryConfig
Source§impl Default for RetryConfig
impl Default for RetryConfig
Source§impl<'de> Deserialize<'de> for RetryConfig
impl<'de> Deserialize<'de> for RetryConfig
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
Auto Trait Implementations§
impl Freeze for RetryConfig
impl RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl UnsafeUnpin for RetryConfig
impl UnwindSafe for RetryConfig
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