pub struct RetryConfig {
pub max_retries: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub jitter: bool,
pub respect_retry_after: bool,
}Expand description
Automatic-retry policy for a Client, set via ClientBuilder::retry.
Retries are opt-in (a client built without one never retries) and deliberately conservative about which failures are safe to repeat:
429 Too Many Requestsis retried for any method (the server rejected the request before acting on it;Retry-Afteris honored when present).5xxresponses and transport errors (timeout/connect/request) are retried only for idempotent methods (GET/PUT/DELETE/HEAD/OPTIONS/TRACE) – never for a barePOST, which may have partially applied server-side.4xxother than429is never retried.
Delay grows as base_delay * 2^attempt, capped at max_delay. With
jitter on (the default) the actual sleep is a uniform random draw in
[0, delay] (“full jitter”), spreading retries so a fleet of clients
doesn’t stampede a recovering server in lockstep.
Fields§
§max_retries: u32Maximum number of additional attempts after the first. 0 disables
retrying entirely.
base_delay: DurationFirst-retry delay; doubles each subsequent attempt.
max_delay: DurationUpper bound on any single computed delay (also caps a large
Retry-After).
jitter: boolApply full jitter to each delay.
respect_retry_after: boolHonor a Retry-After response header (seconds form) in place of the
computed backoff, still capped by max_delay.