pub struct RetryConfig {
pub max_attempts: u32,
pub backoff: BackoffStrategy,
pub retry_status_codes: Vec<u16>,
pub retry_on_connection_error: bool,
pub retry_on_timeout: bool,
pub max_retry_time: Option<Duration>,
}Expand description
Retry configuration.
Fields§
§max_attempts: u32Maximum number of retry attempts.
backoff: BackoffStrategyBackoff strategy.
retry_status_codes: Vec<u16>Status codes that should trigger a retry.
retry_on_connection_error: boolWhether to retry on connection errors.
retry_on_timeout: boolWhether to retry on timeout errors.
max_retry_time: Option<Duration>Maximum total time for all retries.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn exponential(max_attempts: u32, initial_delay: Duration) -> Self
pub fn exponential(max_attempts: u32, initial_delay: Duration) -> Self
Create a retry config with exponential backoff.
Sourcepub fn linear(max_attempts: u32, delay: Duration) -> Self
pub fn linear(max_attempts: u32, delay: Duration) -> Self
Create a retry config with linear backoff.
Sourcepub fn constant(max_attempts: u32, delay: Duration) -> Self
pub fn constant(max_attempts: u32, delay: Duration) -> Self
Create a retry config with constant delay.
Sourcepub fn with_status_codes(self, codes: Vec<u16>) -> Self
pub fn with_status_codes(self, codes: Vec<u16>) -> Self
Set additional status codes to retry on.
Sourcepub fn no_retry_on_connection(self) -> Self
pub fn no_retry_on_connection(self) -> Self
Disable retry on connection errors.
Sourcepub fn no_retry_on_timeout(self) -> Self
pub fn no_retry_on_timeout(self) -> Self
Disable retry on timeout errors.
Sourcepub fn with_max_retry_time(self, duration: Duration) -> Self
pub fn with_max_retry_time(self, duration: Duration) -> Self
Set maximum total retry time.
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Calculate delay for a given attempt.
Sourcepub fn should_retry_status(&self, status: u16) -> bool
pub fn should_retry_status(&self, status: u16) -> bool
Check if a status code should trigger a retry.
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 RetryStrategy for RetryConfig
impl RetryStrategy for RetryConfig
Source§fn should_retry(&self, attempt: u32, error: &HttpClientError) -> bool
fn should_retry(&self, attempt: u32, error: &HttpClientError) -> bool
Check if the request should be retried.
Source§fn retry_delay(&self, attempt: u32) -> Duration
fn retry_delay(&self, attempt: u32) -> Duration
Get the delay before the next retry.
Auto Trait Implementations§
impl Freeze for RetryConfig
impl RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin 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