pub struct RetryConfig {
pub max_retries: u32,
pub wait: WaitStrategy,
pub retry_on: RetryCondition,
pub reraise: bool,
}Expand description
Configuration for retry behavior.
Fields§
§max_retries: u32Maximum number of retries.
wait: WaitStrategyWait strategy.
retry_on: RetryConditionRetry condition.
reraise: boolWhether to reraise the last error if all retries fail.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn new() -> RetryConfig
pub fn new() -> RetryConfig
Create a new default config.
Sourcepub fn max_retries(self, n: u32) -> RetryConfig
pub fn max_retries(self, n: u32) -> RetryConfig
Set max retries.
Sourcepub fn wait(self, strategy: WaitStrategy) -> RetryConfig
pub fn wait(self, strategy: WaitStrategy) -> RetryConfig
Set the wait strategy.
Sourcepub fn exponential(self, initial: Duration, max: Duration) -> RetryConfig
pub fn exponential(self, initial: Duration, max: Duration) -> RetryConfig
Use exponential backoff.
Sourcepub fn exponential_jitter(
self,
initial: Duration,
max: Duration,
jitter: f64,
) -> RetryConfig
pub fn exponential_jitter( self, initial: Duration, max: Duration, jitter: f64, ) -> RetryConfig
Use exponential backoff with jitter.
Sourcepub fn fixed(self, delay: Duration) -> RetryConfig
pub fn fixed(self, delay: Duration) -> RetryConfig
Use fixed delay.
Sourcepub fn linear(
self,
initial: Duration,
increment: Duration,
max: Duration,
) -> RetryConfig
pub fn linear( self, initial: Duration, increment: Duration, max: Duration, ) -> RetryConfig
Use linear backoff.
Sourcepub fn retry_on(self, condition: RetryCondition) -> RetryConfig
pub fn retry_on(self, condition: RetryCondition) -> RetryConfig
Set retry condition.
Sourcepub fn reraise(self, reraise: bool) -> RetryConfig
pub fn reraise(self, reraise: bool) -> RetryConfig
Set whether to reraise the last error.
Sourcepub fn for_api() -> RetryConfig
pub fn for_api() -> RetryConfig
Create config for API calls with sensible defaults.
Sourcepub fn no_retry() -> RetryConfig
pub fn no_retry() -> RetryConfig
Create config that never retries.
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§fn default() -> RetryConfig
fn default() -> RetryConfig
Returns the “default value” for a type. 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 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