Interface ISpendMeter

A persisted per-account meter. Every method is safe to call from several processes at once against one store: two reservations cannot both take the last unit, and a reservation settles exactly once.

interface ISpendMeter {
    reserve(req): Promise<SpendReserveResult>;
    settle(req): Promise<SpendSettleResult>;
    heartbeat(operationId, now?): Promise<void>;
    reconcile(opts?): Promise<SpendReconcileResult>;
    snapshot(accountId, now?): Promise<SpendMeterSnapshot>;
    setAllowance(accountId, allowance, now?): Promise<void>;
}

Implemented by

Methods

  • Pushes a live reservation's lease forward while its turn runs.

    Parameters

    • operationId: string
    • Optional now: number

    Returns Promise<void>

  • Writes the current period's allowance at once after a plan change; the units used stay. A store that reads the product's allowance at every reservation takes the product's answer again at the next one.

    Parameters

    • accountId: string
    • allowance: number
    • Optional now: number

    Returns Promise<void>