interface LockManager_2

Lock abstraction. This interface is used inside of Eventicle to provide semaphore access to shared resources. Notably, this obtains exclusive locks around AggregateRoot instances when processing inside of Commands and Saga steps.

Properties

tryLock

Obtain a lock over a shared resource.

If the lock is not immediately available, will call onLockFailure and terminate

Signature
tryLock: <T>(id: string, onLock: () => Promise<T>, onLockFailure: (e?: Error) => void) => Promise<T>;

withLock

Obtain a lock over a shared resource.

Will block until the lock becomes available.

Will call onLockFailure if the lock is not available within the built in timeout

Signature
withLock: <T>(id: string, onLock: () => Promise<T>, onLockFailure: (e?: Error) => void) => Promise<T>;