UNPKG

syncguard

Version:

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

19 lines (18 loc) 771 B
import type { Firestore } from "@google-cloud/firestore"; import type { LockBackend } from "../common/backend.js"; import type { FirestoreBackendOptions } from "./types.js"; /** * Creates a Firestore-based distributed lock backend * * IMPORTANT: This backend requires a Firestore index for optimal performance: * - Collection: {collection} (default: "locks") * - Field: lockId * - Type: Single field index (ascending) * * Without this index, release() and extend() operations will be slow and may fail. * * @param db Firestore instance * @param options Backend-specific configuration options * @returns LockBackend implementation for Firestore */ export declare function createFirestoreBackend(db: Firestore, options?: FirestoreBackendOptions): LockBackend;