pub struct RetryPolicy {
pub max_retries: u32,
pub backoff_initial: Duration,
pub backoff_max: Duration,
pub jitter: f64,
pub statuses: Vec<u16>,
pub respect_retry_after: bool,
pub retry_connection_errors: bool,
pub budget: Option<Duration>,
}Expand description
When and how long to wait before retrying. The defaults match TypeSafe’s official SDKs:
max_retries(2): retries after the first attempt; 0 disables retryingbackoff_initial(500 ms) andbackoff_max(5 s): the delay doubles each attempt up to the maximumjitter(0.25): the fraction of each delay randomly taken off, from 0 to 1statuses: HTTP statuses that are retried: 408, 429 and every 5xx, which includes TypeSafe’s 529 (overloaded)respect_retry_after(true): wait as long asretry-after-msorretry-aftersaysretry_connection_errors(true): retry timeouts and failed connectionsbudget(30 s): total time per call, including waits. A retry whose wait would pass it is not attempted.Nonefor no limit.
use std::time::Duration;
use typesafe::RetryPolicy;
let patient = RetryPolicy {
max_retries: 5,
budget: Some(Duration::from_secs(60)),
..RetryPolicy::default()
};
let never = RetryPolicy::disabled();Fields§
§max_retries: u32§backoff_initial: Duration§backoff_max: Duration§jitter: f64§statuses: Vec<u16>§respect_retry_after: bool§retry_connection_errors: bool§budget: Option<Duration>Implementations§
Source§impl RetryPolicy
impl RetryPolicy
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 (const: unstable) · 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
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
impl StructuralPartialEq 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