-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Right now, require('flexlock/createLocker')
only allows a single key to lock towards lock(key, ...)
but some code requires multiple resources to work, a new API that works like lock([keyA, keyB], ...)
would be good. The obvious implementation would be to just use Promise.all
to await three locks, but a more-complex implementation that allows other sublocks to receive early might be not a bad idea. In an example:
- (A)
lock(['users', 'user:11'], ...)
→ ... processing - (B)
lock(['users', 'user:12'], ...)
→ ... waiting for (A) to finish - (C)
lock('user:12')
→ processing - (A) finished, (B) → waiting for (C) to finish
- (C) finished, (B) → processing
- (B) finished
In that example (C) can start processing without waiting for (B) to finish because it only uses part of the resources of (B). This would require a more complicated implementation though.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed