Skip to main content

Module ratelimit

Module ratelimit 

Source
Expand description

Per-host request gate: shared, adaptive rate limiting for concurrent fetches.

See ADR-0016. The gate lives inside a reused crate::fetch::HttpClient so concurrent MCP tool calls (and a CLI batch) coordinate their pacing toward a single host — preventing the self-inflicted 429 burst that a fresh-client-per-call fundamentally cannot. It is reactive, not proactive: it honors a server Retry-After where present and, for hosts that send none, applies a bounded escalating cooldown learned from consecutive throttles.

This is complementary to the per-request retry of ADR-0015: that reacts within one request; this schedules across concurrent requests. The two waits are one budget — a request holds its host permit through its own retry, so it never waits on the cooldown it just set.

Structs§

HostGate
The shared per-host gate. Cheap to clone-share via Arc (as it is inside HttpClient).