Zookeeper-like distributed server, WIP.
Via npm on Node:
npm install simplekeeper
Reference in your program:
var simplekeeper = require('simplekeeper');
In the current version (0.0.1) only local server is implemented, with two flavors: synchronous and asynchronous.
Create a server
var server = simplekeeper.createSyncServer('simplekeeper');
Get value
var value = server.getValue('/user/1/name');
Return null if path does not exist.
Set value
server.setValue('/user/1/name', 'adam');
server.setValue('/user/1/age', 800);
Get children
var names = server.getChildren('/user/1'); // ['name', 'age']
Delete node (and its children, if any)
server.delete('/user/1');
Exists node
server.exists('/user/1'); // false after deletoin
Invalid path (throws exceptions)
server.getValue(null); // null
server.getValue(123); // not a string
server.getValue(''); // empty string
server.getValue('foo'); // it does not start with /
Create a server
var server = simplekeeper.createServer('simplekeeper');
Its functions are the same of a synchronous server, but with a callback. I.e.: Get Value
var value = server.getValue('/user/1/name', function (err, value) { ... } );
An asynchronous server can be exposed to other machines:
server.listen(port, host);
A remote client:
var client = simplekeeper.createClient(port, host, function (server) {
// server is a reference to the remote server, with the same interface
server.setValue('/user/1/name', 'Adam', callback);
});
git clone git://github.com/ajlopez/SimpleKeeper.git
cd SimpleKeeper
npm install
npm test
TBD
- Samples
- Set Leader
- Distributed Server
- Invalid path when it ends with /
- 0.0.1: Published
- 0.0.2: Under development, in master. Leader server. Distributed servers
Feel free to file issues and submit pull requests — contributions are welcome.
If you submit a pull request, please be sure to add or update corresponding
test cases, and ensure that npm test
continues to pass.