How to use the zookeeper.ZooKeeper.on_connected function in zookeeper

To help you get started, we’ve selected a few zookeeper 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 killme2008 / node-zk-browser / zk.js View on Github external
function new_zk(hosts,zkclient){
    var zk = new ZK();
    zk.init ({connect:hosts, timeout:20000, debug_level:ZK.ZOO_LOG_LEVEL_WARNING, host_order_deterministic:false});
    zk.on (ZK.on_connected, function (zkk) {
        console.log ("zk session established, id=%s", zkk.client_id);
    });
    zk.on(ZK.on_closed,function(zkk){
        //re-initialize
        console.log("zk session close,re-init it");
        zkclient.zk=new_zk(hosts,zkclient);
    });
    return zk;
}