How to use the node-zookeeper-client.Id function in node-zookeeper-client

To help you get started, we’ve selected a few node-zookeeper-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NetEase / pomelo / lib / monitors / zookeepermonitor.js View on Github external
this.spinDelay = opts.spinDelay || constants.TIME.DEFAULT_SPIN_DELAY;
  this.reconnectTimes = opts.reconnectTimes || constants.RETRY.RECONNECT_RETRY;

  this.nodePath = this.path + '/' + app.serverType +
    constants.RESERVED.ZK_NODE_SEP + app.serverId;

  this.cmdPath = this.path + '/' +
    constants.RESERVED.ZK_NODE_COMMAND + app.serverId;

  this.authentication = this.username + ':' + this.password;

  const shaDigest = crypto.createHash('sha1')
                          .update(this.authentication)
                          .digest('base64');

  const id = new zookeeper.Id('digest', this.username + ':' + shaDigest);
  this.acls = [new zookeeper.ACL(zookeeper.Permission.ALL, id)];

  this.client = zookeeper.createClient(this.servers, {
    sessionTimeout: this.timeout,
    retries: this.retries,
    spinDelay: this.spinDelay
  });
}