Full-featured async client for locker lock server
Switch branches/tags
Nothing to show
Latest commit 3b818ac Jun 10, 2012 @bobrik bobrik added package file
Failed to load latest commit information.
example added example code Jun 10, 2012
lib initial working commit Jun 10, 2012
.gitignore ignore webstorm files Jun 10, 2012
README.md added README file Jun 10, 2012
index.js initial working commit Jun 10, 2012
package.json added package file Jun 10, 2012


node-locker - full-featured client for locker lock server

Allows to lock common resources across servers with sub-second precision in node.js in async way.


Check out locker server page for server installation instructions.

npm install locker


var Locker = require("locker"),
    locker = new Locker(4545, "");

locker.on("reset", function() {
    console.log("Reset happened (is server running?)");

locker.on("error", function(error) {
    console.log("Catched error:", error);

//            name    wait  max   callback
locker.locked("five", 2000, 3000, function(error, callback) {
    if (error) {
        // lock failed

    // do whatever you want with your shared resource

    callback(undefined, {well: "done"});


  • Requiring
var Locker = require("Locker");
  • New connection
var locker = new Locker(port, host);
  • Locking resource
locker.locked(identifier, lock_wait_time, max_execution_time, callback)

callback signature:

function(error, next) {}

In callback you will be exclusive owner of resource with name identifier if there is no error argument.

After doing exclusive stuff you should release lock by calling next callback.


  • reset — connection was reset and all locks were gone.
  • error - error occurred on some of connection locks (timeout exceed for waiting or execution time)