pub struct HostGate { /* private fields */ }Expand description
The shared per-host gate. Cheap to clone-share via Arc (as it is inside HttpClient).
Implementations§
Source§impl HostGate
impl HostGate
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Build a gate, letting environment variables override the tunable defaults (ADR-0016).
Sourcepub async fn acquire(&self, url: &str) -> Result<OwnedSemaphorePermit, RssError>
pub async fn acquire(&self, url: &str) -> Result<OwnedSemaphorePermit, RssError>
Acquire the right to send a request to url’s host, waiting out any active cooldown /
spacing. Returns the permit guard (released on drop, including on cancellation) or a
RssError::RateLimited if the required wait exceeds max_gate_wait.
Sourcepub fn note_throttled(&self, url: &str, retry_after: Option<Duration>)
pub fn note_throttled(&self, url: &str, retry_after: Option<Duration>)
Record a 403/429 from url’s host: extend the sibling cooldown and mark the host
warm. retry_after is the server’s honored value (any form) when present; otherwise a
bounded escalation of the base cooldown is used.
Sourcepub fn note_success(&self, url: &str)
pub fn note_success(&self, url: &str)
Record a non-throttled response from url’s host: reset the escalation counter so the
next throttle starts from the base cooldown again. warm_until is left to decay on its
own, so a host that just recovered keeps light spacing briefly.