import type { PostgresAdapter, PostgresConfig } from "../postgres/index.js"; import { type StatePrefixConfig } from "../state-prefix.js"; import type { PathwayCoordinator } from "./types.js"; /** * Options for {@link PostgresPathwayCoordinator}. * * Set `statePrefix` when several deployables share ONE connection string. An * explicit `leasesTable` or `instancesTable` always wins over the prefix. */ export interface PostgresPathwayCoordinatorOptions extends StatePrefixConfig { /** Explicit lease table name. Overrides `statePrefix`. Default: `"pathway_leases"`. */ leasesTable?: string; /** Explicit instance table name. Overrides `statePrefix`. Default: `"pathway_instances"`. */ instancesTable?: string; } /** * PostgreSQL-backed implementation of PathwayCoordinator. * Uses two tables: * - `pathway_leases`: distributed locks for leader election * - `pathway_instances`: instance registration and heartbeating * * Both table names, and the leader lease key, are namespaced by the optional * `statePrefix`. Without a prefix the historical names are used unchanged. */ export declare class PostgresPathwayCoordinator implements PathwayCoordinator { private adapter; private initialized; private readonly leasesTable; private readonly instancesTable; /** * Leader lease key for this coordinator, namespaced by `statePrefix`. * * `ClusterManager` reads this so a prefix set here alone is enough — the same * value does not have to be repeated in the cluster options. */ readonly leaseKey: string; constructor(adapter: PostgresAdapter, options?: PostgresPathwayCoordinatorOptions); private ensureInitialized; acquireLease(instanceId: string, key: string, ttlMs: number): Promise; renewLease(instanceId: string, key: string, ttlMs: number): Promise; releaseLease(instanceId: string, key: string): Promise; register(instanceId: string, address: string): Promise; heartbeat(instanceId: string): Promise; unregister(instanceId: string): Promise; getInstances(staleThresholdMs: number): Promise>; } /** * Factory function to create a PostgresPathwayCoordinator * * @param config PostgreSQL connection configuration * @param options Table naming options, including the optional `statePrefix` * * @example * ```typescript * // Two deployables that share one connection string * const coordinator = await createPostgresPathwayCoordinator( * { connectionString: process.env.DATABASE_URL! }, * { statePrefix: "compute_api" }, * ) * ``` */ export declare function createPostgresPathwayCoordinator(config: PostgresConfig, options?: PostgresPathwayCoordinatorOptions): Promise; //# sourceMappingURL=postgres-coordinator.d.ts.map