LockManager
Defined in: queue/lock.ts:13
Lock manager for distributed coordination
Type Parameters
Section titled “Type Parameters”T extends QueueItem = QueueItem
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LockManager<
T>(storage,defaultTimeout?):LockManager<T>
Defined in: queue/lock.ts:14
Parameters
Section titled “Parameters”storage
Section titled “storage”QueueStorage<T>
defaultTimeout?
Section titled “defaultTimeout?”number = ...
Returns
Section titled “Returns”LockManager<T>
Methods
Section titled “Methods”getLockHolder()
Section titled “getLockHolder()”getLockHolder():
Promise<string|null>
Defined in: queue/lock.ts:63
Get current lock holder
Returns
Section titled “Returns”Promise<string | null>
isLocked()
Section titled “isLocked()”isLocked():
Promise<boolean>
Defined in: queue/lock.ts:56
Check if currently locked
Returns
Section titled “Returns”Promise<boolean>
tryWithLock()
Section titled “tryWithLock()”tryWithLock<
R>(holder,fn,timeout?):Promise<R|null>
Defined in: queue/lock.ts:40
Try to execute a function with a lock Returns null if lock cannot be acquired
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”holder
Section titled “holder”string
() => Promise<R>
timeout?
Section titled “timeout?”number
Returns
Section titled “Returns”Promise<R | null>
waitForRelease()
Section titled “waitForRelease()”waitForRelease(
maxWaitMs?,checkIntervalMs?):Promise<boolean>
Defined in: queue/lock.ts:72
Wait for lock to be released Returns true if lock was released, false if timeout
Parameters
Section titled “Parameters”maxWaitMs?
Section titled “maxWaitMs?”number = 30000
checkIntervalMs?
Section titled “checkIntervalMs?”number = 1000
Returns
Section titled “Returns”Promise<boolean>
withLock()
Section titled “withLock()”withLock<
R>(holder,fn,timeout?):Promise<R>
Defined in: queue/lock.ts:23
Execute a function with a lock Automatically acquires and releases the lock
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”holder
Section titled “holder”string
() => Promise<R>
timeout?
Section titled “timeout?”number
Returns
Section titled “Returns”Promise<R>