Created
October 19, 2012 23:12
-
-
Save vvo/3921228 to your computer and use it in GitHub Desktop.
bad session event behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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