@drupflare/workforce - v0.3.0
    Preparing search index...

    Class Budget

    One credential's share of the API.

    Keyed by CREDENTIAL rather than by account: two accounts reached with one token share a budget, because the limit counts the user. Two tokens cannot be proven to belong to one user from outside, so the default is one budget per token, which is conservative and right whenever a user holds one.

    Index
    concurrency: number
    reserve: number
    • Waits until one request may be spent.

      Blocks on two things: the concurrency cap, and the reserve. Crossing the reserve waits for the window to roll rather than throwing, because a fleet operation that is merely slow is a better outcome than one that half-applied and stopped.

      Returns Promise<void>

    • refuses rather than waiting, for a caller that would rather fail fast

      Returns void

    • Folds a response's own headers in, which is what makes this track reality.

      The server's count wins over the local one whenever it reports one, since the local count cannot see the dashboard or another process holding the same token.

      Parameters

      • headers: Headers

      Returns void

    • treats a 429 as authoritative: the window is spent until it says otherwise

      Parameters

      • headers: Headers

      Returns number

    • returns the slot; the spend itself is not returned, because the API counted it

      Returns void

    • what the governor currently believes, for a status line or a test

      Returns { floor: number; quota: number; remaining: number; resetsInMs: number }