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.

17 lines (16 loc) 916 B
import { type AcquireResult, type KeyOp } from "../../common/backend.js"; import type { RedisCapabilities, RedisConfig } from "../types.js"; /** Redis client with eval support and optional cached script command */ interface RedisWithCommands { eval(script: string, numKeys: number, ...args: (string | number)[]): Promise<unknown>; acquireLock?(lockKey: string, lockIdKey: string, fenceKey: string, lockId: string, ttlMs: string, toleranceMs: string, storageKey: string, // ADR-013: Full lockKey (post-truncation) for index storage userKey: string): Promise<[number, string, number] | number>; } /** * Creates Redis acquire operation with atomic script execution. * @see ../scripts.ts for Lua script details */ export declare function createAcquireOperation(redis: RedisWithCommands, config: RedisConfig): (opts: KeyOp & { ttlMs: number; }) => Promise<AcquireResult<RedisCapabilities>>; export {};