Watchers and Callbacks

lusis edited this page Jan 17, 2011 · 2 revisions

Watchers and Callbacks

ZooKeeper implements a concept of a Watcher. When you register a watcher against a znode, you are notified of any changes to that znode. Obviously in a RESTful disconnected system, that becomes a bit more complicated but I'd like to implement it. The challenge is how to propagate those notifications back to registered watchers?

Callbacks

The initial plan is that, when you register a watch, you provide the following:

  • A client name (who are you?) This will probably require you to register as a Host
  • An endpoint Probably in some sort of URI format
  • An event What event do you want to watch? Right now, I'm thinking that you would register multiple events as opposed to watching all events for a given object (Host, Service, Application, Configuration).
  • An action Register the watch, deregister the watch?

Endpoints

I'd like callback endpoint support to be pluggable. Initially, I'll probably support at least:

  • Webhooks provide a URL and we'll send you some JSON
  • Redis PubSub you tell us to which Redis channel you want us to push the message

These should be pretty easy to implement. The key is figuring out the best way to handle this in conjunction with the main REST interface. Do I provide a second running application to handle watches or do I start a thread inside of the main application?

Other options I'm considering are AMQP, XMPP and Atom/RSS.

Underneath all the callbacks will still be still be a Redis PubSub setup.