/** * Job Lock for preventing concurrent execution * * Simple in-memory lock mechanism for single-process environments. * For multi-process scenarios, use a distributed lock (Redis, etc.) */ /** * Lock information */ export interface LockInfo { /** Job ID */ jobId: string; /** When lock was acquired */ acquiredAt: Date; /** Lock timeout in ms (0 = no timeout) */ timeout: number; } export declare class JobLock { private locks; private readonly defaultTimeout; /** * Create a new JobLock instance * * @param defaultTimeout - Default lock timeout in ms (0 = no timeout) */ constructor(defaultTimeout?: number); /** * Attempt to acquire a lock for a job * * @param jobId - Job identifier * @param timeout - Lock timeout in ms (overrides default) * @returns true if lock acquired, false if already locked */ acquire(jobId: string, timeout?: number): boolean; /** * Release a lock for a job * * @param jobId - Job identifier * @returns true if lock was released, false if not locked */ release(jobId: string): boolean; /** * Check if a job is currently locked * * Also handles timeout expiration. * * @param jobId - Job identifier * @returns true if locked, false otherwise */ isLocked(jobId: string): boolean; /** * Get lock information for a job * * @param jobId - Job identifier * @returns Lock info or null if not locked */ getLockInfo(jobId: string): LockInfo | null; /** * Get all currently held locks * * @returns Array of lock info */ getAllLocks(): LockInfo[]; /** * Release all locks */ releaseAll(): void; /** * Get the number of currently held locks */ get size(): number; /** * Execute a function with a lock * * Automatically acquires and releases lock around the function. * * @param jobId - Job identifier * @param fn - Function to execute * @param timeout - Lock timeout in ms * @returns Result of the function * @throws Error if lock cannot be acquired */ withLock(jobId: string, fn: () => Promise, timeout?: number): Promise; } //# sourceMappingURL=job-lock.d.ts.map