You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using redlock in a big project, and I started looking into upgrading since we want to upgrade ioredis to v5. A few suggestions:
can we have a double signature on the acquire function so it accepts both a string and an array of strings. this will make migrating much easier for most users. And I think in general the more common usecase will be a lock on 1 resource:
public async acquire(
resources: string | string[],
why can the lock.release() still throw an error? in the examples you put lock.release() in the finally section, however this function can also throw an ExecutionError. So we would have to do something like this:
let lock: Lock | null = null;
try {
lock = await redLock.acquire([`...`], 15000);
// do some stuff
} catch (error) {
if (error instanceOf ResourceLockedError) {
console.log('failed to acquire the lock on the resource');
}
console.log(error)
} finally {
await lock?.release().catch(ExecutionError, () => {
console.log('failed to release the lock on the update. This can indicate that the lock expired prior to unlocking it');
});
}
this makes everything a bit convoluted. I would let the release of the lock fail silently.
The text was updated successfully, but these errors were encountered:
Hi,
We are using redlock in a big project, and I started looking into upgrading since we want to upgrade ioredis to v5. A few suggestions:
acquire
function so it accepts both a string and an array of strings. this will make migrating much easier for most users. And I think in general the more common usecase will be a lock on 1 resource:lock.release()
in thefinally
section, however this function can also throw an ExecutionError. So we would have to do something like this:this makes everything a bit convoluted. I would let the release of the lock fail silently.
The text was updated successfully, but these errors were encountered: