Name: zookeeper-cluster-client
Owner: node_modules
Description: Sharing one zookeeper connection among Multi-Process on Node.js
Created: 2017-07-25 04:09:20.0
Updated: 2018-05-20 02:02:42.0
Pushed: 2018-04-12 08:12:50.0
Homepage: null
Size: 36
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Support cluster-client process model on node-zookeeper-client.
i zookeeper-cluster-client --save
1. Create a node using given path:
t zookeeper = require('zookeeper-cluster-client');
t client = zookeeper.createClient('localhost:2181');
t path = process.argv[2];
nt.once('connected', async function() {
ait client.create(path);
nsole.log('Node: %s is successfully created.', path);
ait client.close();
nt.connect();
2. List and watch the children of given node:
t zookeeper = require('zookeeper-cluster-client');
t client = zookeeper.createClient('localhost:2181');
t path = process.argv[2];
c function listChildren(client, path) {
nst children = await client.getChildren(
path,
event => {
console.log('Got watcher event: %s', event);
listChildren(client, path);
});
nsole.log('Children of %s are: %j.', path, children);
nt.once('connected', () => {
nsole.log('Connected to ZooKeeper.');
stChildren(client, path);
nt.connect();
createClient(connectionString, [options])
connect()
close()
: return promiseasync create(path, [data], [acls], [mode])
async remove(path, [version])
async setData(path, data, [version])
async getACL(path, [options])
async setACL(path, acls, [version])
async mkdirp(path, [data], [acls], [mode])
async exists(path, [watcher])
async getChildren(path, [watcher], [options])
async getData(path, [watcher], [options])
addAuthInfo(scheme, auth)
State getState()
Buffer getSessionId()
Buffer getSessionPassword()
Number getSessionTimeout()
transaction()
Provides some useful APIs beyond node-zookeeper-client.
[x] watch(path, listener)
nt.watch('/foo', (err, data, stat) => {
err) {
handle error
turn;
ole.log('data => %s', data.toString());
ole.log('stat => %s', stat);
[x] watchChildren(path, listener)
nt.watchChildren('/foo', (err, children, stat) => {
err) {
handle error
turn;
ole.log('children => %j', children);
ole.log('stat => %s', stat);