Skip to content

Instantly share code, notes, and snippets.

@vvo
Created October 19, 2012 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvo/3921228 to your computer and use it in GitHub Desktop.
Save vvo/3921228 to your computer and use it in GitHub Desktop.
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