Skip to content

Struct client::RetryPolicy

zaun_community_protocol::client::RetryPolicy · Struct

pub struct RetryPolicy { … }

Exponential backoff: initial_ms, then ×factor, capped at cap_ms; give up once give_up_ms have passed since the first send.

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.

Delay before the first retry.

Multiplier per attempt.

Largest delay.

Total time after which a request is abandoned.

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.

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.

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.

pub const fn resend_now(&self, due_ms: u64, heard_ms: Option<u64>, now_ms: u64) -> bool

Whether a resend due at due_ms goes out at now_ms, the host last heard at heard_ms: once the host has been silent for initial_ms, or cap_ms after it was due, whatever the host is sending.

pub const fn expired(&self, first_ms: u64, now_ms: u64) -> bool

Whether a request first sent at first_ms is abandoned at now_ms.

Clone, Copy, Debug, Default, Eq, PartialEq, StructuralPartialEq

Full rustdoc page