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

Feature request: Ability to lock the same key from different services (or methods) via Lock decorator. #21

Closed OsoianMarcel closed 2 months ago

OsoianMarcel commented 9 months ago

Problem: I have a resource (for example, ID 123), so I need a distributed lock across different applications and different services. Currently, the Murlock decorator generates a lock key that includes the service name and method name as part of the lock key, so I can not lock the same resource (ID 123) with different service names or different method names because the lock key will be different. I know this was made by design. It would be great to have another lock decorator where the lock key does not include the service name and method name, so the user would have full control over the lock key name. I'm aware that I can directly utilize the lock service, but employing a TypeScript Decorator would add a touch of elegance.

Some ideas:

Thank you.

felanios commented 9 months ago

Hi @OsoianMarcel, thank you for your feedback and support, I will look at the feature you want and take care of it as soon as possible.

felanios commented 9 months ago

Hi @OsoianMarcel, I couldn't look at the package due to work, but I haven't forgotten your request. I'll take care of it as soon as I get the chance, I just wanted to keep you informed.

ledmago commented 2 months ago

Hey @OsoianMarcel, The new version is released. you can use lockKeyPrefix in the root of module 🙌🏻