UNPKG

syncguard

Version:

Functional TypeScript library for distributed locking across microservices. Prevents race conditions with Redis, PostgreSQL, Firestore, and custom backends. Features automatic lock management, timeout handling, and extensible architecture.

16 lines (15 loc) 784 B
import type { Firestore } from "@google-cloud/firestore"; import type { LockBackend } from "../common/backend.js"; import type { FirestoreBackendOptions, FirestoreCapabilities } from "./types.js"; /** * Creates Firestore-based distributed lock backend using transactions. * * IMPORTANT: Requires composite index on lockId field for release()/extend() performance. * See firebase.json for index configuration. * * @param db - Firestore instance from @google-cloud/firestore * @param options - Backend configuration (collection, ttl, tolerance) * @returns LockBackend with client-side time authority * @see docs/specs/firestore-backend.md */ export declare function createFirestoreBackend(db: Firestore, options?: FirestoreBackendOptions): LockBackend<FirestoreCapabilities>;