Releases: ori88c/zero-overhead-keyed-promise-lock
Releases · ori88c/zero-overhead-keyed-promise-lock
Update dependencies, add Prettier for formatting
Enable smart reuse via getCurrentExecution method to expose the active task's promise for a specific key
Key Features ✨
- Smart Reuse ♻️: In scenarios where launching a duplicate task would be wasteful (e.g., refreshing a shared resource or cache), consumers can await the ongoing execution instead of scheduling a new one. This is enabled via the
getCurrentExecutionmethod, which exposes the currently executing task's promise for a specific key, if one is active.
README Enhancements
Key Features ✨
- Enhance README with a graceful teardown example for
StockOrdersConsumer, not just the batch handler.
Improve coding examples in README, add negative test for invalid key
Key Features ✨
- Improve coding examples in README.
- Add negative test for invalid key.
README improvements
Key Features ✨
- README improvements.
First Release
Key Features ✨
- Key-wise Mutual Exclusiveness 🔒: Ensures the mutually exclusive execution of tasks associated with the same key, either to prevent potential race conditions caused by tasks spanning across multiple event-loop iterations, or to optimize performance.
- Graceful Teardown ⏳: Await the completion of all currently pending and executing tasks using the
waitForAllExistingTasksToCompletemethod. Example use cases include application shutdowns (e.g.,onModuleDestroyin Nest.js applications) or maintaining a clear state between unit-tests. A particularly interesting use case is in batch processing handlers, where it allows you to signal the completion of all event handlers associated with a batch. - "Check-and-Abort" Friendly 🙈: The
isActiveKeygetter allows skipping or aborting operations if a lock is already held. - Active Key Metrics 📊: The
activeKeysgetter provides real-time insight into currently active keys - i.e., keys associated with ongoing tasks. - Even-Driven Eviction of Stale Keys: Automatically removes internal locks for keys with no pending or ongoing tasks, ensuring the lock never retains stale keys.
- Comprehensive documentation 📚: Fully documented to provide rich IDE tooltips and enhance the development experience.
- Thoroughly Tested 🧪: Covered by extensive unit tests to ensure reliability.
- Minimal External Dependencies: Internally manages multiple instances of zero-overhead-promise-lock, one per active key. This package focuses on efficient resource management while leveraging a well-tested foundation. Both packages are maintained by the same author 💙, with all other dependencies limited to development.
- ES2020 Compatibility: The
tsconfigtarget is set to ES2020. - TypeScript support.