felanios / murlock

MurLock: A distributed locking solution for NestJS, providing a decorator for critical sections with Redis-based synchronization. Ideal for microservices and scalable applications.
https://www.npmjs.com/package/murlock
MIT License
73 stars 3 forks source link

Could we not throw an exception on release? #34

Closed Scoup closed 8 months ago

Scoup commented 9 months ago

I have a low latency project, usually with ttl below 500ms, but sometimes we have spikes, and when this happens the flow is broken because the service can't release the key (because it already expired with TTL). I don't know why my application would throw an error when trying to release a key (the app can't recover from this). Can we at least have this throw as optional? I could open a PR with this option.

felanios commented 9 months ago

Hi @Scoup, yeap we can make optional to throw unlock side.

ssijak commented 8 months ago

@Scoup you can just do .catch(ex => {...}) and swallow the exception on release or just log it

felanios commented 8 months ago

Hi @Scoup, I added a flag named ignoreUnlockFail to handle your request. If it's true unlock method's exception will be only logged. You can check this version https://www.npmjs.com/package/murlock/v/3.1.0

Scoup commented 8 months ago

@felanios thanks for the update!!