Builds a gate that opens immediately (no pause is pending).
Duration to pause when the server doesn't provide
a usable Retry-After header.
Whether the gate is currently closed (caller should not make requests).
true while the rate-limit window is active.
Convenience: record the rate-limit and emit a formatted error log
in one call. Centralizes the log message format so the consuming
API clients stay consistent, and avoids repeating the
recordRateLimit(...) + logger.error(...) pair at each 429
call site.
Logger used to emit the error line.
Error-level log sink.
Header value from the 429 response (delta-seconds or HTTP-date).
Record a rate-limit response from upstream.
Accepts the raw Retry-After header value in either RFC 9110
form: delta-seconds ("120") or an HTTP-date
("Wed, 21 Oct 2026 07:28:00 GMT"). Unparsable, zero, negative,
past-dated, or missing values fall back to the configured duration.
OptionalretryAfter: unknown
Header value from the 429 response.
Atomic read of the gate's state. All fields are computed against a
single Temporal.Now.instant() capture, so remaining and
unblockAt cannot observe inconsistent "one null, one not" pairs
that separate getter reads might hit near the boundary.
Returned as a discriminated union on isPaused so callers do not
need to null-check remaining / unblockAt after narrowing.
The current pause state and derived timing fields.
Tracks an upstream rate-limit window and lets callers check whether the gate is currently closed.
Used by the consuming API clients to honor HTTP 429 responses: record the rate-limit on the error path (respecting
Retry-Afterwhen present) and consultisPaused/remainingon the request path to fail fast without hammering the upstream server.