Minimalist single thread ordered lock for distributed clients.
yarn add ordered-lock
import {Client} from 'ordered-lock';
let client = new Client({
connect: {
host: 'ordered-lock',
port: 3292,
},
lock: {
ttl: 2,
lockingTimeout: 10,
},
});
client.lock('123', async extend => {
// ...
extend(2);
});
client.lock(['123', '456'], async extend => {
// ...
});
You probably don't need to use the server library, check out the Docker image.
import {Server} from 'ordered-lock/server';
// ...
docker pull makeflow/ordered-lock
It listens on port 3292
.
MIT License.