gatelineAPI reference

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

interface GovernorPort {
    spendWindowMs: number;
    register(
        repository: string,
        opts?: { displayName?: string; spendLimitUsd?: null | number },
    ): void;
    registered(repository: string): boolean;
    report(
        repository: string,
        gather: () => SpendReport | Promise<SpendReport>,
    ): Promise<void>;
    reserve(request: ReservationRequest): ReserveResult;
    seed(repository: string, entries: SeedEntry[]): void;
    subscribe(repository: string, wake: () => Promise<void>): () => void;
    uncounted(): string[];
    unregister(repository: string, opts?: { uncounted?: boolean }): void;
    unseeded(): string[];
}

Implemented by

Properties

spendWindowMs: number

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

Methods

  • 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

    • repository: string
    • Optionalopts: { displayName?: string; spendLimitUsd?: null | number }

    Returns void

  • Whether the repository is registered now (not unregistered, not unknown).

    Parameters

    • repository: string

    Returns boolean

  • 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>

  • Be woken when a slot this repository was refused may be free. Returns the unsubscribe.

    Parameters

    • repository: string
    • wake: () => Promise<void>

    Returns () => void

  • 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 (#502), for an engine that has stopped. Its live reservations and startup holds are released, and it leaves the round-robin and the seed gate. What it spent inside the window keeps counting against the machine's window until the window rolls past it: the money was spent whether or not its engine still runs.

    Parameters

    • repository: string
    • Optionalopts: { uncounted?: boolean }

    Returns void