Skip to content
Browse files

added README file

  • Loading branch information...
1 parent 6c85ed7 commit eca618447e1caba6a1f538aafea0b469f8a1c3bb @bobrik committed Jun 10, 2012
Showing with 68 additions and 0 deletions.
  1. +68 −0 READEME.md
View
68 READEME.md
@@ -0,0 +1,68 @@
+locker - lock server written in node.js
+===========================
+
+This is lock server for system that need to share and lock common resources across servers with sub-second precision.
+
+It allows to set wait timeout for lock and max execution time to limit your desire for eternal locking.
+
+## Clients
+
+### node.js
+
+[Client for node.js](https://github.com/bobrik/node-locker) is completely async.
+
+Example
+
+```javascript
+var Locker = require("locker"),
+ locker = new Locker(4545, "127.0.0.1");
+
+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
+ callback(error);
+ return;
+ }
+
+ // do whatever you want with your shared resource
+
+ callback(undefined, {well: "done"});
+});
+```
+
+## Running
+
+First create a dir for locker:
+
+```
+mkdir locker
+cd locker
+mkdir node_modules
+npm install locker-server
+```
+
+Then create main server file (look at `example/server.js`) and save it as `server.js`:
+
+```javascript
+(function() {
+ var Locker = require("../index"),
+ locker = new Locker();
+
+ locker.listen(4545);
+})();
+```
+
+Run it after all:
+
+```
+node server.js
+```

0 comments on commit eca6184

Please sign in to comment.
Something went wrong with that request. Please try again.