import type { BackendCapabilities } from "../common/backend.js"; import type { OnReleaseError } from "../common/disposable.js"; /** * PostgreSQL backend capabilities with server-side time authority. */ export interface PostgresCapabilities extends BackendCapabilities { backend: "postgres"; supportsFencing: true; timeAuthority: "server"; } /** * Configuration options for PostgreSQL backend. */ export interface PostgresBackendOptions { /** * Table name for lock storage. * @default "syncguard_locks" */ tableName?: string; /** * Table name for fence counter storage. * @default "syncguard_fence_counters" */ fenceTableName?: string; /** * Enable opportunistic cleanup in isLocked operation. * @default false */ cleanupInIsLocked?: boolean; /** * Callback for release errors during disposal (optional) */ onReleaseError?: OnReleaseError; /** * Timeout for automatic disposal operations in ms (optional) */ disposeTimeoutMs?: number; } /** * Internal configuration after applying defaults and validation. */ export interface PostgresConfig { tableName: string; fenceTableName: string; cleanupInIsLocked: boolean; onReleaseError?: OnReleaseError; disposeTimeoutMs?: number; } /** * Lock row structure in syncguard_locks table. */ export interface LockRow { key: string; lock_id: string; expires_at_ms: string; acquired_at_ms: string; fence: string; user_key: string; } /** * Fence counter row structure in syncguard_fence_counters table. */ export interface FenceRow { fence_key: string; fence: string; key_debug: string | null; }