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
62 stars 1 forks source link

Could we not throw an exception on release? #34

Closed Scoup closed 6 months ago

Scoup commented 6 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 6 months ago

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

ssijak commented 6 months ago

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

felanios commented 6 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 6 months ago

@felanios thanks for the update!!