arango-lock

0.4.0 • Public • Published

Build Status dependencies Status devDependencies Status

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

Package Sidebar

Install

npm i arango-lock

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

6.8 kB

Total Files

4

Last publish

Collaborators

  • xploratics