Skip to main content

Module conditional

Module conditional 

Source
Expand description

Conditional requests and rate-limit back-off, as a transport decorator.

ConditionalTransport wraps any HttpTransport and:

  • remembers the ETag of every successful GET and sends it back as If-None-Match; a 304 is answered from the cached body (so callers see a normal 200) and, on GitHub, costs no rate limit;
  • reads each host’s rate-limit headers – interpreted per API family, because the six products do not mean the same thing by them (see [rate_observation]) – and, once a host says “none left”, refuses further requests to it until the reset time instead of hammering it (Error::RateLimited);
  • exposes a short human note (ConditionalTransport::rate_note) when a host is close to its limit, for the TUI’s status line.

Every client is rebuilt per refresh in the TUI, so the cache lives here (one shared instance), not in the clients.

Structs§

ConditionalTransport

Functions§

shared_network_transport
The process-wide caching network transport (created on first use).
shared_rate_note
The shared transport’s rate note, without creating the transport.