Full-featured client for locker lock server with timeouts support
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 = 4545 "127.0.0.1";lockeron"reset"console.log"Reset happened (is server running?)";;lockeron"error"console.log"Catched error:" error;;// name wait max callbacklockerlocked"five" 2000 3000if error// lock failedcallbackerror;return;// do whatever you want with your shared resourcecallbackundefined well: "done";;
var Locker = require"Locker";
var locker = port host;
lockerlockedidentifier lock_wait_time max_execution_time callback
callback you will be exclusive owner of resource with name
identifier if there is no
After doing exclusive stuff you should release lock by calling
reset— connection was reset and all locks were gone.
error- error occurred on some of connection locks (timeout exceed for waiting or execution time)