pub struct RetryPolicy {
pub initial_ms: u64,
pub factor: u64,
pub cap_ms: u64,
pub give_up_ms: u64,
}Expand description
Exponential backoff: initial_ms, then ×factor, capped at cap_ms; give up once
give_up_ms have passed since the first send (§7.3: 5 s, ×2, 60 s, 24 h).
A resend also waits until the host has been silent for initial_ms (at most cap_ms
longer): while its messages are still arriving, the answer is most likely among them.
Fields§
§initial_ms: u64Delay before the first retry.
factor: u64Multiplier per attempt.
cap_ms: u64Largest delay.
give_up_ms: u64Total time after which a request is abandoned.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn delay(&self, attempt: u32) -> u64
pub fn delay(&self, attempt: u32) -> u64
The delay after send number attempt (1 = the first send): 5 s, 10 s, 20 s, 40 s,
then 60 s.
Sourcepub fn refused_delay(&self, attempt: u32) -> u64
pub fn refused_delay(&self, attempt: u32) -> u64
The delay after a transient error on send number attempt: 2 s, 4 s, 8 s, … 60 s,
never longer than RetryPolicy::delay.
Sourcepub fn next_at(
&self,
now_ms: u64,
attempt: u32,
error: Option<&ErrorBody>,
) -> u64
pub fn next_at( &self, now_ms: u64, attempt: u32, error: Option<&ErrorBody>, ) -> u64
The next send time after send number attempt at now_ms: the backoff, or after a
transient error its RetryPolicy::refused_delay or, if later, its
retry_after_ms.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more