import type { CircuitStateStore, SharedCircuitState } from '../ops/circuit-breaker.js'; import { type PostgresLikeClient } from './client.js'; /** Options for the Postgres circuit store. */ export interface PostgresCircuitStateStoreOptions { /** Table name, optionally schema-qualified. Defaults to `nexus_circuits`. */ table?: string; /** Clock for probe leases. Defaults to `Date.now`, the same clock the breaker uses. */ now?: () => number; } /** The schema, as statements. */ export declare function circuitStoreMigration(options?: Pick): string[]; /** * Shared circuit state in Postgres. * * Both operations the breaker needs to be atomic are single statements: a transition is written only * when it is at least as new as the stored one, and a probe is claimed only when no other worker holds * an unexpired claim. One row per provider, so a sync reads a handful of rows. */ export declare class PostgresCircuitStateStore implements CircuitStateStore { private readonly client; private readonly options; private readonly table; private readonly now; constructor(client: PostgresLikeClient, options?: PostgresCircuitStateStoreOptions); /** Creates the table if it does not exist. Never runs implicitly. */ migrate(): Promise; /** Every provider's shared circuit state. */ read(): Promise; /** * Writes a transition, unless a newer one is already stored. Releases the provider's probe claim. */ write(state: SharedCircuitState): Promise; /** * Claims the right to probe a provider for `ttlMs`, in one statement. Resolves true for the * claimant, including when it already holds the claim. */ claimProbe(providerName: string, owner: string, ttlMs: number): Promise; }