cluster-readwrite-lock
Read/Write locks on asynchronous code, across a worker cluster.
cluster-readwrite-lock gives you a readwrite lock that you can use across all your workers in a forked NodeJS process. This gives your multiprocess application the ability to handle the same data without causing race conditions between its workers.
Installation
npm install cluster-readwrite-lock
Features
- Uses ES6 promises
- Individual or an array of lock keys supported
- Timeout supported
- Pending task limit supported
Usage Example
const cluster = ;const ClusterReadwriteLock = ;const lock = cluster; { return { ; };} { return { fs };} if clusterisMaster for let i = 0; i < 4; ++i cluster; else lock; lock; lock;
Getting Started
/** * @param * @param * @param */lock; /** * @param * @param * @param */lock;
Options
// Specify timeoutvar lock = cluster timeout : 5000;lock ;lock ; // Set max pending tasksvar lock = cluster maxPending : 1000;lock ;lock ; // Use your own promise library instead of the global Promise variablevar lock = cluster Promise : ; // Bluebirdvar lock = cluster Promise : Promise; // Q
Issues
See isse tracker.
License
MIT, see LICENSE