node-redlock
node-redlock copied to clipboard
Add ability to cancel lock acquisition
I have a function that requests a lock, but it handles some events, so I would like to cancel the lock acquire if one of the events is fired. I saw the documentation but didn't find anything for this purpose.
This is not currently possible, but is an interesting idea.
The RedLock inherits from the Node EventEmitter, so it probably possible to do something:
myLock = require('RedLock');
myLock.on('unlock', function(...args) {
const parameters = args.join(', ');
console.log(`parameters ${parameters} for unlock`);
// some code
});
myLock.emit('unlock', parameters );
can you try it
I would definitely be open to providing a mechanism for this using the AbortController standard, but also will likely not have a chance to implement it myself. Marking as "help wanted".
I will look into it again in the following weeks