pub struct RetryPolicy {
pub max_retries: u32,
pub initial_delay_ms: u64,
pub multiplier: f64,
pub max_jitter_ms: u64,
pub max_delay_ms: u64,
pub retry_on_timeout: bool,
pub retry_on_connection_error: bool,
pub retry_on_5xx: bool,
pub retry_on_429: bool,
}Expand description
Retry policy
Fields§
§max_retries: u32Maximum number of attempts
initial_delay_ms: u64Initial delay (ms)
multiplier: f64Backoff multiplier
max_jitter_ms: u64Max jitter (ms)
max_delay_ms: u64Max delay (ms)
retry_on_timeout: boolRetry on timeout errors
retry_on_connection_error: boolRetry on connection errors
retry_on_5xx: boolRetry on 5xx server errors
retry_on_429: boolRetry on 429 rate limit errors
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Calculates the delay for a given attempt (with jitter)
Sourcepub fn should_retry(&self, error: &Error, attempt: u32) -> bool
pub fn should_retry(&self, error: &Error, attempt: u32) -> bool
Should we retry this error?
Sourcepub fn should_retry_status(&self, status_code: u16, attempt: u32) -> bool
pub fn should_retry_status(&self, status_code: u16, attempt: u32) -> bool
Should we retry this HTTP status code?
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 · 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 RetryPolicy
impl Debug 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 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