Create a better lock instance
Optional
options: BetterLockOptionsStatic
DEFAULT_Default options to be used when creating BetterLock instances.
Abort all jobs for a given key (or from the default job queue, if no key is given). Job executors will not be called. Callbacks will be called with JobAbortedError. Currently executing job will not be interrupted.
Optional
key: BetterLockKeyAbort all pending jobs from all queues. Currently executing jobs will not be interrupted.
Acquire the lock for given key or list of keys. If waiting on a list, keys will be acquired in order, as they become free. Any deadlock prevention must be handled by the caller.
Once the lock is acquired, we will call the executor function, with a "done" method. You must call "done" to release the lock. Alternatively, return a Promise; lock will be released once promise resolves or rejects.
Return values from your executor will be passed to callback (or the resulting promise).
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
Acquire the lock for given key or list of keys. If waiting on a list, keys will be acquired in order, as they become free. Any deadlock prevention must be handled by the caller.
Once the lock is acquired, we will call the executor function, with a "done" method. You must call "done" to release the lock. Alternatively, return a Promise; lock will be released once promise resolves or rejects.
Return values from your executor will be passed to callback (or the resulting promise).
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
Acquire the lock for given key or list of keys. If waiting on a list, keys will be acquired in order, as they become free. Any deadlock prevention must be handled by the caller.
Once the lock is acquired, we will call the executor function, with a "done" method. You must call "done" to release the lock. Alternatively, return a Promise; lock will be released once promise resolves or rejects.
Return values from your executor will be passed to callback (or the resulting promise).
Function that will run inside the lock. Required.
Function to be called after the executor finishes or if we never enter the lock (timeout, queue depletion). Leave out to use promises.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
Acquire the lock for given key or list of keys. If waiting on a list, keys will be acquired in order, as they become free. Any deadlock prevention must be handled by the caller.
Once the lock is acquired, we will call the executor function, with a "done" method. You must call "done" to release the lock. Alternatively, return a Promise; lock will be released once promise resolves or rejects.
Return values from your executor will be passed to callback (or the resulting promise).
Named key or array of keys for this particular call. Calls with different keys will be run in parallel. Not required.
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
Acquire the lock for given key or list of keys. If waiting on a list, keys will be acquired in order, as they become free. Any deadlock prevention must be handled by the caller.
Once the lock is acquired, we will call the executor function, with a "done" method. You must call "done" to release the lock. Alternatively, return a Promise; lock will be released once promise resolves or rejects.
Return values from your executor will be passed to callback (or the resulting promise).
Named key or array of keys for this particular call. Calls with different keys will be run in parallel. Not required.
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
Acquire the lock for given key or list of keys. If waiting on a list, keys will be acquired in order, as they become free. Any deadlock prevention must be handled by the caller.
Once the lock is acquired, we will call the executor function, with a "done" method. You must call "done" to release the lock. Alternatively, return a Promise; lock will be released once promise resolves or rejects.
Return values from your executor will be passed to callback (or the resulting promise).
Named key or array of keys for this particular call. Calls with different keys will be run in parallel. Not required.
Function that will run inside the lock. Required.
Function to be called after the executor finishes or if we never enter the lock (timeout, queue depletion). Leave out to use promises.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
The same as acquire, except if the lock can't be acquired (the executor never gets called), instead of throwing
an error, the lock will resolve/callback with the provided failureResult value (for example, a null
).
The value to return if the executor never get called. This happens instead of rejecting.
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
The same as acquire, except if the lock can't be acquired (the executor never gets called), instead of throwing
an error, the lock will resolve/callback with the provided failureResult value (for example, a null
).
The value to return if the executor never get called. This happens instead of rejecting.
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
The same as acquire, except if the lock can't be acquired (the executor never gets called), instead of throwing
an error, the lock will resolve/callback with the provided failureResult value (for example, a null
).
The value to return if the executor never get called. This happens instead of rejecting.
Function that will run inside the lock. Required.
Function to be called after the executor finishes, or there is an execution timeout. Leave out to use promises.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
The same as acquire, except if the lock can't be acquired (the executor never gets called), instead of throwing
an error, the lock will resolve/callback with the provided failureResult value (for example, a null
).
Named key or array of keys for this particular call. Calls with different keys will be run in parallel. Not required.
The value to return if the executor never get called. This happens instead of rejecting.
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
The same as acquire, except if the lock can't be acquired (the executor never gets called), instead of throwing
an error, the lock will resolve/callback with the provided failureResult value (for example, a null
).
Named key or array of keys for this particular call. Calls with different keys will be run in parallel. Not required.
The value to return if the executor never get called. This happens instead of rejecting.
Function that will run inside the lock. Required.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
The same as acquire, except if the lock can't be acquired (the executor never gets called), instead of throwing
an error, the lock will resolve/callback with the provided failureResult value (for example, a null
).
Named key or array of keys for this particular call. Calls with different keys will be run in parallel. Not required.
The value to return if the executor never get called. This happens instead of rejecting.
Function that will run inside the lock. Required.
Function to be called after the executor finishes, or there is an execution timeout. Leave out to use promises.
Optional
jobOptions: BetterLockJobOptionsOptions to be applied on this job only
Returns true if the caller can immediately acquire the lock. There is nothing holding the key and nothing in the queue.
Optional
key: stringGenerated using TypeDoc
Main better lock class.