gatelineAPI reference

The seam (#34): what an engine needs from whatever admits its dispatches. Governor is the in-process implementation.

Implements

Constructors

Properties

spendWindowMs: number

The window the spend limits measure over — engines read their ledgers back this far.

Methods

  • Spend in the window across every registered repository: closed cost and open or reserved estimates.

    Parameters

    • OptionalrequesterLabel: string
    • Optionalsuperseded: ReadonlySet<string>

    Returns { closed: number; open: number }

  • Make a repository known: it enters the spend sum and the round-robin, and must seed before anything is granted. displayName is how the refusal words name it (#502); the key is used when there is none.

    Parameters

    • label: string
    • opts: { displayName?: string; spendLimitUsd?: null | number } = {}

    Returns void

  • The repository's ledgers, read by gather. Replaces its previous report. The governor calls gather itself so that it knows which settlements the report can have seen: those released before gather began. A report that arrives after a newer one has been applied is ignored.

    Parameters

    Returns Promise<void>

  • One repository's spend in the window. Closed entries opened inside the window at their real cost (an undated one counts — the ceiling bounds unattended spend, and a fact it cannot date is not a reason to spend more), plus dispatches that settled since the report began gathering, at the cost they were released with. Then entries still open at their estimate, and the governor's own reservations and startup holds at theirs. Every dispatch is counted once, however the report, the reservation and the settlement overlap:

    • a settlement or a committed reservation that the report shows closed (same key, same at) counts only as that closed entry;
    • an open entry the report still lists but that has since settled counts only as settled;
    • an open entry and a reservation or hold with the same key count once.

    A settlement leaves the window like a closed entry, by when it settled, whether or not its repository reports again. superseded names holds a request is about to take over, so their estimate is not counted beside the request's own.

    Parameters

    • label: string
    • Optionalsuperseded: ReadonlySet<string>

    Returns { closed: number; open: number }

  • What the governor holds right now, for the heartbeat and for tests. The counts are read from the same maps reserve reads, never recomputed.

    Returns {
        holds: number;
        occupied: number;
        offers: Record<string, number>;
        reservations: number;
        settled: number;
        uncommitted: number;
        uncommittedUsd: number;
        waiters: string[];
    }

    • holds: number
    • occupied: number
    • offers: Record<string, number>
    • reservations: number
    • settled: number

      Settled dispatches counted by the governor until a report replaces them.

    • uncommitted: number
    • uncommittedUsd: number
    • waiters: string[]
  • The repositories the machine's spend window is not counting (#502): each was unregistered after its startup seed failed or timed out, before it ever reported, so what it spent in the window is unknown to the governor until it seeds. Empty unless a machine spend limit is enforced, since only then is anything decided on that sum.

    Returns string[]

  • Forget a repository whose engine has stopped (#502).

    Slots and the seed gate are freed. Its live reservations are released (a later release() of one does nothing), its startup holds and any slot offered to it are dropped, it leaves the round-robin — the turn passes to the repository after it — and the governor no longer waits for it to seed. Every repository refused meanwhile is woken.

    Money is not. What it spent inside the window was real, and dropping it would let the others spend the machine's window twice over. So its closed entries and settlements in the window stay in the machine's sum at what they cost, and leave it as the window rolls past them, exactly as they would have. Entries still open, holds and live reservations stay in the sum at their estimate, dated now: a detached role may still be running, and its cost is not known. An undated closed entry is dated now too, so it leaves the window one window from now rather than never.

    None of it counts toward the repository's own ceiling, which is gone with it. If the repository registers again, its first report replaces what it left behind, since that report reads the same ledgers.

    Parameters

    • label: string
    • opts: { uncounted?: boolean } = {}

    Returns void