Releases: ori88c/zero-overhead-promise-lock
Releases · ori88c/zero-overhead-promise-lock
Bugfix: A rejecting task caused all other pending tasks to reject without execution
Key Features ✨
- Fixed a bug where a rejecting task caused all other pending tasks to reject without execution. A rigorous test was added to prevent regressions. The issue stemmed from an over-optimization attempt.
README and Documentation improvements
Key Features ✨
- README and Documentation improvements.
Backpressure Metric was added
Key Features ✨
- Backpressure Metric was added 📊: The
pendingTasksCount
getter provides a real-time metric indicating the current backpressure from tasks waiting for the lock to become available. Users can leverage this data to make informed decisions, such as throttling, load balancing, or managing system load. Additionally, this metric can aid in internal resource management within a containerized environment. If multiple locks exist - each tied to a unique key - a backpressure value of 0 may indicate that a lock is no longer needed and can be removed temporarily to optimize resource usage.
First Release
Key Features ✨
- Mutual Exclusiveness 🔒: Ensures the mutually exclusive execution of asynchronous tasks, either to prevent potential race conditions caused by tasks spanning across multiple event-loop iterations, or for performance optimization.
- Graceful Termination ⏳: Await the completion of all currently pending and executing tasks using the
waitForAllExistingTasksToComplete
method. Example use cases include application shutdowns (e.g.,onModuleDestroy
in Nest.js applications) or maintaining a clear state between unit-tests. - Suitable for "check and abort" scenarios: The
isAvailable
getter indicator enables to skip or abort operations if the lock is currently held by another task. - High Efficiency ⚙️: Leverages the Node.js microtasks queue to serve tasks in FIFO order, eliminating the need for manually managing an explicit queue of pending tasks.
- Comprehensive documentation 📚: The class is thoroughly documented, enabling IDEs to provide helpful tooltips that enhance the coding experience.
- Tests 🧪: Fully covered by extensive unit tests.
- No external runtime dependencies: Only development dependencies are used.
- ES2020 Compatibility: The
tsconfig
target is set to ES2020. - TypeScript support.