Expand description
Explicit HTTP retry policy for crates.io / docs.rs (Rules Rust — retry/backoff).
§Workload and policy scope
- Dependency: public HTTPS hosts only (
crates.io,docs.rs,static.docs.rs,doc.rust-lang.org). - Operations: product surface is GET-only (idempotent by HTTP semantics). No POST/PUT/DELETE; no Idempotency-Key required.
- Default: retries on for transient failures (agent reliability).
Kill switch:
--disable-retry/ TOMLdisable_retry = true/max_retries = 0. - Layer: single retry loop inside
crate::http::HttpClientonly — no middleware stack, no nested client retries, no agent-level auto-retry of permanent kinds.
§Delay formula
cap(n) = min(base_ms * 2^min(n, 16), max_delay_ms)
delay = uniform(0..=cap) // full jitter (AWS architecture blog)Relógio monotônico: sleeps usam tokio::time::sleep (não SystemTime).
Retry-After delta-seconds overrides the formula for 429/503 when present.
HTTP-date Retry-After is not parsed (no chrono dep); falls back to formula.
§Out of scope (one-shot agent CLI)
Circuit breaker, retry budget token-bucket, hedged requests, gRPC, OAuth refresh, outbox/saga, multi-host sticky sessions.
Structs§
- Retry
Config - Named retry policy for the product HTTP client (one dependency class).
Enums§
- Retry
Class - Classification of an HTTP status for the retry gate.
Constants§
- DEFAULT_
MAX_ RETRIES - Default maximum retries after the first attempt (total attempts = N+1).
- DEFAULT_
RETRY_ BASE_ MS - Default base backoff in milliseconds (also minimum floor for formula).
- DEFAULT_
RETRY_ MAX_ DELAY_ MS - Default ceiling for a single backoff sleep (milliseconds).
- HARD_
MAX_ DELAY_ MS - Hard ceiling for a single delay (milliseconds).
- HARD_
MAX_ RETRIES - Hard cap on configured retries (prevents accidental retry storms).
Functions§
- backoff_
full_ jitter - Full jitter:
uniform(0..=min(base*2^attempt, max_delay)). - classify_
http_ status - Classify HTTP status for in-process retry (GET-only product).
- parse_
retry_ after - Parse
Retry-Afteras delta-seconds only. - politeness_
delay - Per-host politeness delay with additive jitter (never below the configured floor).
- wait_
for_ retry - Prefer server
Retry-Afterwhen present; otherwise full-jitter formula.