pub struct RetryPolicy {
pub max_retries: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub backoff_multiplier: f64,
pub retry_on_status: Vec<StatusCode>,
pub retry_on_timeout: bool,
}Expand description
Configures retry behavior for failed requests.
Supports exponential backoff with jitter to avoid thundering herd problems.
§Example
use typeway_client::RetryPolicy;
use std::time::Duration;
let policy = RetryPolicy::default()
.max_retries(5)
.initial_backoff(Duration::from_millis(200));Fields§
§max_retries: u32Maximum number of retry attempts (0 = no retries).
initial_backoff: DurationInitial backoff duration before the first retry.
max_backoff: DurationMaximum backoff duration (caps exponential growth).
backoff_multiplier: f64Multiplier applied to the backoff after each attempt.
retry_on_status: Vec<StatusCode>Status codes that trigger a retry.
retry_on_timeout: boolWhether to retry on request timeouts.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn max_retries(self, n: u32) -> Self
pub fn max_retries(self, n: u32) -> Self
Set the maximum number of retry attempts.
Sourcepub fn initial_backoff(self, d: Duration) -> Self
pub fn initial_backoff(self, d: Duration) -> Self
Set the initial backoff duration.
Sourcepub fn max_backoff(self, d: Duration) -> Self
pub fn max_backoff(self, d: Duration) -> Self
Set the maximum backoff duration.
Sourcepub fn backoff_multiplier(self, f: f64) -> Self
pub fn backoff_multiplier(self, f: f64) -> Self
Set the backoff multiplier.
Sourcepub fn retry_on_status(self, codes: Vec<StatusCode>) -> Self
pub fn retry_on_status(self, codes: Vec<StatusCode>) -> Self
Set which status codes should trigger retries.
Sourcepub fn retry_on_timeout(self, enabled: bool) -> Self
pub fn retry_on_timeout(self, enabled: bool) -> Self
Set whether timeouts should trigger retries.
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 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