How to build an IO operations plugin?

#1

I have built a libcouchbase wrapper for python which I am using in the Tornado framework. Tornado includes an ioloop for handling asynchronous events. For now I am calling lcb_wait() to complete libcouchbase operations, but I would like to start using it fully asynchronously, driven by the Tornado ioloop.

The blog post about driving libcouchbase with your own libevent event loop makes reference to creating a plugin:
libcouchbase performs it’s IO through an “IO handle”. This is a plugin system so you should be able to use whatever mechanism you want. Adding support for a new system is nothing more than implementing a handfull of function calls and place them in a shared object.

I have not found any documentation for the plugin system. I’ve looked at the source for the libevent & libev plugins and I could perhaps figure it out from them, but I’d feel a lot more comfortable doing so with a little guidance. Is there anything written that I can work from?

#2

There are several external implementations:

  1. example with libev
    https://github.com/avsej/libev-couchbase-example

  2. ruby GVL-friendly implementation
    https://github.com/couchbase/couchbase-ruby-client/blob/master/ext/couch

  3. ruby eventmachine (should be similar to twisted)
    https://github.com/couchbase/couchbase-ruby-client/blob/master/ext/couch

  4. perl anyevent implementation
    https://github.com/mnunberg/perl-Couchbase-Client/blob/master/xs/async_e

  5. node.js libuv implementation
    https://github.com/couchbase/couchnode/blob/master/src/ioplugin.cc