libev and Apache ZooKeeper
Ride Shoot Speak
ride.shoot.speak at googlemail.com
Sat Feb 12 15:05:24 CET 2011
I'm trying to implement a node.js extension for Apache ZooKeeper C API. As
some probably know node.js relies on libev for its event loop. ZooKeeper
uses a callback mechanism to report certain event to the application. For
zhandle_t zk = zookeeper_init(zkHost, watcherCallback, zkTimeout, 0, hw,
static void watcherCallback(zhandle_t * zh, int type, int state, const
char * path, void * watcherCtx)
// handle events here
The ZooKeeper C API tries to connect to the ZooKeeper server asynchronously.
As soon as it gets a connection it calls the applications callback with an
event. The application then can read or write data to the ZooKeeper. I want
to emit node.js events from the callback so that a node.js script can react
My problem is that node quits as soon as the ZooKeeper C API gets connected
to the ZooKeeper server. The callback isn't even called. To my knowledge
node.js quits when the event loop is stopped. My guess is that something in
ZooKeeper causes something in node.js and/or libev to exit the event loop. I
already had a quick look in the ZooKeeper code but not sure what to search
for. Any ideas what the problem could be or what to look for in ZooKeeper?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the libev