lib/serviceDiscovery/engines/zookeeper/index.js
function createZooKeeperClient(options) {
	options = options || {};

	if (!options.hosts) {
		throw new Error('Missing configuration server.discoveryService.options.hosts for ZooKeeper');
	}

	// client options, with better defaults than node-zookeeper-client provides

	var clientOpts = options.options || {};

	clientOpts.sessionTimeout = clientOpts.hasOwnProperty('sessionTimeout') ? clientOpts.sessionTimeout : 30000;
	clientOpts.spinDelay = clientOpts.hasOwnProperty('spinDelay') ? clientOpts.spinDelay : 1000;
	clientOpts.retries = clientOpts.hasOwnProperty('retries') ? clientOpts.retries : 3;

	// connect to the database

	var client = zooKeeper.createClient(options.hosts, clientOpts);

	client.on('connected', function () {
		logger.verbose('ZooKeeper connection established');
	});

	client.on('connectedReadOnly', function () {
		logger.error('ZooKeeper connection established to a read-only server');
	});

	client.on('disconnected', function () {
		logger.verbose('ZooKeeper connection dropped');
	});

	client.on('expired', function () {
		logger.verbose('ZooKeeper client session expired');
	});

	client.on('authenticationFailed', function () {
		logger.error('ZooKeeper authentication failed');
	});

	return client;
}
function createZooKeeperClient(options) {
	options = options || {};

	if (!options.hosts) {
		throw new Error('Missing configuration server.discoveryService.options.hosts for ZooKeeper');
	}

	// client options, with better defaults than node-zookeeper-client provides

	var clientOpts = options.options || {};

	clientOpts.sessionTimeout = clientOpts.hasOwnProperty('sessionTimeout') ? clientOpts.sessionTimeout : 30000;
	clientOpts.spinDelay = clientOpts.hasOwnProperty('spinDelay') ? clientOpts.spinDelay : 1000;
	clientOpts.retries = clientOpts.hasOwnProperty('retries') ? clientOpts.retries : 3;

	// connect to the database

	var client = zooKeeper.createClient(options.hosts, clientOpts);

	client.on('connected', function () {
		logger.verbose('ZooKeeper connection established');
	});

	client.on('connectedReadOnly', function () {
		logger.error('ZooKeeper connection established to a read-only server');
	});

	client.on('disconnected', function () {
		logger.verbose('ZooKeeper connection dropped');
	});

	client.on('expired', function () {
		logger.verbose('ZooKeeper client session expired');
	});

	client.on('authenticationFailed', function () {
		logger.error('ZooKeeper authentication failed');
	});

	return client;
}
function createZooKeeperClient ( options ) { options = options || { } ; if ( ! options . hosts ) { throw new Error ( 'Missing configuration server.discoveryService.options.hosts for ZooKeeper' ) ; } // client options, with better defaults than node-zookeeper-client provides var clientOpts = options . options || { } ; clientOpts . sessionTimeout = clientOpts . hasOwnProperty ( 'sessionTimeout' ) ? clientOpts . sessionTimeout : 30000 ; clientOpts . spinDelay = clientOpts . hasOwnProperty ( 'spinDelay' ) ? clientOpts . spinDelay : 1000 ; clientOpts . retries = clientOpts . hasOwnProperty ( 'retries' ) ? clientOpts . retries : 3 ; // connect to the database var client = zooKeeper . createClient ( options . hosts , clientOpts ) ; client . on ( 'connected' , function ( ) { logger . verbose ( 'ZooKeeper connection established' ) ; } ) ; client . on ( 'connectedReadOnly' , function ( ) { logger . error ( 'ZooKeeper connection established to a read-only server' ) ; } ) ; client . on ( 'disconnected' , function ( ) { logger . verbose ( 'ZooKeeper connection dropped' ) ; } ) ; client . on ( 'expired' , function ( ) { logger . verbose ( 'ZooKeeper client session expired' ) ; } ) ; client . on ( 'authenticationFailed' , function ( ) { logger . error ( 'ZooKeeper authentication failed' ) ; } ) ; return client ; }
Creates a zookeeper client, sets up relevant event listeners and connects.

@param {Object} options
@returns {zooKeeper.client}
Creates a zookeeper client sets up relevant event listeners and connects .