Skip to content

Instantly share code, notes, and snippets.

@vvo
Created Oct 19, 2012
Embed
What would you like to do?
bad session event behavior
var zk = require('../lib');
var async = require('async');
if (require.cache[__dirname + '/helper.js'])
delete require.cache[__dirname + '/helper.js'];
var helper = require('./helper.js');
var ZK;
var HOST = process.env.ZK_HOST || 'localhost';
var PORT = parseInt(process.env.ZK_PORT, 10) || 2181;
ZK = zk.createClient({
log: helper.createLogger('zk.client.test.js'),
servers: [ {
host: HOST,
port: PORT
}]
});
var watchcount = 0;
var childrencount = 0;
ZK.watch('/', {method: 'list', initialData: true}, function(err, listener) {
watchcount++;
if (err !== null) {
return console.log(err);
}
listener.on('error', function (err) {
console.error(err.stack);
process.exit(1);
});
listener.on('children', function (children) {
childrencount++;
console.log(childrencount + ' children events');
console.log(watchcount + ' watch function calls');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment