import type { BudgetReservationRecord, BudgetReservationStatus } from '../types/lifecycle.js'; /** * A change to one recorded reservation: where it moves, what it charges once there, and the * statuses it may move from. A store applies the status and the difference in what it charges to its * total together, or not at all. */ export interface BudgetReservationChange { /** Where it moves. */ status: Exclude; /** What it adds to its total once moved. */ charged: number; /** The statuses it may move from. From any other, the change is refused. */ from: readonly BudgetReservationStatus[]; /** When, epoch milliseconds. */ at: number; /** What its operation cost, when settled. */ actual?: number; } /** * Reservations in process memory, beside the totals of the store that holds them: what * `MemoryBudgetUsage` and `MemoryTenantUsage` keep them in. Each change and its total move together, * since nothing runs between them on one thread. */ export declare class MemoryReservationBook { private readonly add; private readonly now; private readonly records; private prunedAt; constructor(add: (key: string, amount: number, resetAt: number) => number, now: () => number); /** Records a reservation and adds what it charges to its total. */ hold(record: BudgetReservationRecord): number; /** Moves a reservation, and its total by what it charges differently, if it stands where `from` allows. */ settle(id: string, change: BudgetReservationChange): boolean; /** Extends a reserved reservation's lease. */ renew(id: string, leasedUntil: number): boolean; /** Reserved reservations whose lease lapsed by `now`, soonest lapsed first. */ lapsed(now: number, limit: number, operation?: string): BudgetReservationRecord[]; /** One reservation. */ get(id: string): BudgetReservationRecord | undefined; /** * Forgets what no report can change any more, at most once a minute: anything whose period has * ended, and a settled, released, or expired reservation after an hour. An uncertain one is kept * for its period, until its operation says what it cost. */ private prune; }