Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zookeeper-cluster-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zookeeper-cluster-client

Sharing one zookeeper connection among Multi-Process on Node.js

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120
increased by26.32%
Maintainers
1
Weekly downloads
 
Created
Source

zookeeper-cluster-client

NPM version build status Test coverage David deps Known Vulnerabilities NPM download

Install

npm i zookeeper-cluster-client --save

Usage

1. Create a node using given path:

const zookeeper = require('zookeeper-cluster-client');
const client = zookeeper.createClient('localhost:2181');
const path = process.argv[2];

client.once('connected', () => {
  console.log('Connected to the server.');
  client.create(path, err => {
    if (err) {
      console.log('Failed to create node: %s due to: %s.', path, err);
    } else {
      console.log('Node: %s is successfully created.', path);
    }
    client.close();
  });
});

client.connect();

2. List and watch the children of given node:

const zookeeper = require('zookeeper-cluster-client');
const client = zookeeper.createClient('localhost:2181');
const path = process.argv[2];

function listChildren(client, path) {
  client.getChildren(
    path,
    event => {
      console.log('Got watcher event: %s', event);
      listChildren(client, path);
    },
    (err, children, stat) => {
      if (err) {
        console.log('Failed to list children of %s due to: %s.', path, err);
        return;
      }
      console.log('Children of %s are: %j.', path, children);
    }
  );
}

client.once('connected', () => {
  console.log('Connected to ZooKeeper.');
  listChildren(client, path);
});

client.connect();

Support APIs

  • createClient(connectionString, [options])
  • connect()
  • close(): return promise
  • create(path, [data], [acls], [mode], callback)
  • remove(path, [version], callback)
  • setData(path, data, [version], callback)
  • getACL(path, callback)
  • setACL(path, acls, [version], callback)
  • mkdirp(path, [data], [acls], [mode], callback)
  • exists(path, [watcher], callback)
  • getChildren(path, [watcher], callback)
  • getData(path, [watcher], callback)
  • addAuthInfo(scheme, auth)
  • State getState()
  • Buffer getSessionId()
  • Buffer getSessionPassword()
  • Number getSessionTimeout()
  • transaction()

License

MIT

FAQs

Package last updated on 28 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc