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.
14 lines (13 loc) • 665 B
TypeScript
import { type LockOp, type ReleaseResult } from "../../common/backend.js";
import type { RedisConfig } from "../types.js";
/** Redis client with eval and optional cached releaseLock method */
interface RedisWithCommands {
eval(script: string, numKeys: number, ...args: (string | number)[]): Promise<unknown>;
releaseLock?(lockIdKey: string, lockId: string, toleranceMs: string): Promise<number>;
}
/**
* Creates release operation with atomic ownership verification and deletion.
* @see redis/scripts.ts
*/
export declare function createReleaseOperation(redis: RedisWithCommands, config: RedisConfig): (opts: LockOp) => Promise<ReleaseResult>;
export {};