How to use the node-zookeeper-client.Event 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 Robinlim / npm_cache_share / src / js / common / zkClient.js View on Github external
/**
 * // Event types
 * var TYPES = {
 *     NODE_CREATED : 1,
 *     NODE_DELETED : 2,
 *     NODE_DATA_CHANGED : 3,
 *     NODE_CHILDREN_CHANGED : 4
 * };
 */
var _ = require('lodash'),
    zookeeper = require('node-zookeeper-client'),
    CreateMode = zookeeper.CreateMode,
    Event = zookeeper.Event;

var zk,
    eventCache = {},
    bindsEvent = {},
    ZKROOT = '/npm_cache_share';

module.exports = {
    Event: Event,
    /**
     * 创建zookeeper clinet
     * @param  {String} zkConfig zookeeper的链接,如host:port
     * @param  {String} zkRoot zookeeper上根路径节点名称
     * @return {void}
     */
    init: function(zkConfig, zkRoot) {
        zk = zookeeper.createClient(zkConfig, {
github wefront / node-codis / dist / index.js View on Github external
this._zkClient.getData(path, function (event) {
            log('Zookeeper getData event emit: %o', event);
            // Retrieve node data when node data changes
            // Result is: getData will listen for NODE_DELETE event when node is deleted, 
            // at the same time getChildren will also listen to the NODE_CHILDREN_CHANGED event.
            // Prevent confusion
            if (event.type === zookeeper.Event.NODE_DATA_CHANGED) {
                _this._state = RECONNECTED;
                _this._getData(path, cb);
            }
        }, function (err, data) {
            if (err) {
github node-modules / zookeeper-cluster-client / lib / index.js View on Github external
const zookeeper = require('node-zookeeper-client');
const ZookeeperClient = require('./api_client');

exports.createClient = (connectionString, options) => {
  options = options || {};
  options.connectionString = connectionString || 'localhost:2181';
  return new ZookeeperClient(options);
};

exports.ACL = zookeeper.ACL;
exports.Id = zookeeper.Id;
exports.Permission = zookeeper.Permission;
exports.CreateMode = zookeeper.CreateMode;
exports.State = zookeeper.State;
exports.Event = zookeeper.Event;
exports.Exception = zookeeper.Exception;
github NetEase / pomelo / lib / master / zookeeper.js View on Github external
var zookeeper = require('node-zookeeper-client');
var CreateMode = zookeeper.CreateMode;
var Event = zookeeper.Event;
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var logger = require('pomelo-logger').getLogger(__filename);

var zookeeperClient = null;

function getClient(app){
  if(!zookeeperClient){
    zookeeperClient = new Zookeeper(app);
  }

  return zookeeperClient;
}

function Zookeeper(app, opts){
  this.app = app;
github MZMonster / node-thrift-service / lib / zookeeper.js View on Github external
let watcher = (event) => {
      if (event.getType() === zookeeper.Event.NODE_CHILDREN_CHANGED) {
        this._zk.getChildren(path, watcher, (error, childrens) => {
          if (error && error.getCode() !== 0) {
            callback(error, []);
          } else {
            callback(null, childrens);
          }
        });
      }
    };
    this._zk.getChildren(path, watcher, () => {
github scality / backbeat / extensions / workflowEngineDataSource / WorkflowEngineDataSourceQueuePopulator.js View on Github external
event => {
                if (event.type ===
                    NodeZookeeperClient.Event.NODE_CHILDREN_CHANGED) {
                    this.log.debug('WEDSQP: children changed');
                    this._updateFilterDescriptors();
                }
            }, err => {
                if (err) {