arango-lock
v0.4.0
Published
Implements locking using arango database
Downloads
5
Maintainers
Readme
arango-lock
Implements locking using arango database.
Installation
npm install arango-lock
Api
lock
Acquire a lock asynchronously allowing concurrent works to continue during locking.
options
- database: arangojs database object
- name: name of the lock
- expiration: expiration of the lock if no beat is received. (Default: 5000ms)
example
var database = require('arangojs')({ url: 'http://localhost:8529' });
var lock = require('arango-lock');
database.useDatabase('db').useBasicAuth('root', 'pass');
lock.acquire({ database, name: 'lock1' })
.then(function (release) {
// lock acquired, do some stuff.
// release the lock after works done.
return release();
});
Test
# 1. mount the database, recreate it if already mounted.
npm run mount-db
# 2. run the tests
npm run test
# 3. unmount the database
npm run unmount-db
Licence
MIT License