API Core - v1.5.0
    Preparing search index...

    Class RateLimitPolicy

    Rate-limit circuit breaker. Two responsibilities:

    1. Short-circuit — if the RateLimitGate is still in a paused window, throw RateLimitError without letting the attempt hit the network. Callers see a fast, typed refusal.
    2. Record — when the attempt comes back with an HTTP 429, arm the gate from the Retry-After header and surface a diagnostic log before re-raising. Subsequent callers see the paused state and refuse immediately (see point 1).

    Ownership: only 429 responses. Any other error (401, 5xx, network) propagates untouched so outer/inner policies can handle it.

    Implements

    Index
    • Refuses fast while the gate is paused, otherwise runs the attempt and records any 429 that comes back.

      Type Parameters

      • T

      Parameters

      • attempt: () => Promise<T>

        The request attempt to decorate.

      Returns Promise<T>

      The attempt's resolved value.

      RateLimitError while the gate is paused.