pub struct RetryConfig {
pub max_retries: u32,
pub initial_backoff_ms: u64,
pub max_backoff_ms: u64,
}Expand description
Configuration for retry-on-429 with exponential backoff.
Fields§
§max_retries: u32Maximum number of retry attempts after the initial request (default: 3).
initial_backoff_ms: u64Base backoff in milliseconds for the first retry, doubled each attempt (default: 500).
max_backoff_ms: u64Upper bound in milliseconds for the backoff delay (default: 10_000).
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn backoff(&self, attempt: u32) -> Duration
pub fn backoff(&self, attempt: u32) -> Duration
Calculate backoff duration with jitter for attempt N.
Uses fastrand for uniform jitter (75%-125% of base delay) to avoid
thundering herd when multiple clients retry simultaneously.
Sourcepub fn retry_delay(&self, attempt: u32, retry_after: Option<&str>) -> Duration
pub fn retry_delay(&self, attempt: u32, retry_after: Option<&str>) -> Duration
The delay before the attempt after attempt: its backoff,
lengthened by the server’s Retry-After.
Retry-After can only extend the wait, never shorten it. A server
asking for longer than the client-computed backoff is obeyed (clamped to
max_backoff_ms); one asking for less — including the zero that
Cloudflare returns alongside error code: 1015 — leaves the exponential
backoff in place. Taking the header verbatim made a tripped Cloudflare
limit self-perpetuating: Duration::from_millis(0) is not a backoff, and
the three retries landed inside 65ms, extending the ban they were waiting
on. Values that do not parse as a float (e.g. the HTTP-date form) are
ignored the same way.
The header is read by polyoxide_venue::parse_retry_after, the one
parser every crate uses, clamped to max_backoff_ms, and the longer
wait is taken by polyoxide_venue::retry_delay.
The send loop’s floor and a policy’s hold both come from here, so a response cannot hold the client by one rule and pace its own retry by another.
Sourcepub fn attempt_info(&self, attempt: u32) -> AttemptInfo
pub fn attempt_info(&self, attempt: u32) -> AttemptInfo
What HttpClient::send tells its hooks
about attempt: the attempt, from 0, and the retries this schedule
still allows after it.