Import couch_dbupdates from rcouch.

This creates a new top level API endpoint: `/_db_updates`
that returns a line of JSON for each database event along
with the database name.

A database event is one of `created`, `updated`, `deleted`.

The API endpoint supports a `?feed=` parameter with the
options: `longpoll`, `continuous` and `eventsource`.

A second parameter `timeout=` specifies when the server should
close the connection.

`longpoll` closes the connection after a single notification.
It is the default option.

`continuous` keeps a socket open until the specified `timeout`
or 60 seconds by default.

`heartbeat` decides whether to send a newline character on
`timeout` to avoid clients closing the connection prematurely.

`eventsource` works like continuous, but sends the data in
EventSource format. See http://dev.w3.org/html5/eventsource/

The parameters are modelled after the existing `/_changes` API
endpoint. Note that `/_db_updates` does not support resuming
of notifications via a sequence ID.

This is a port of the existing DbUpdateNotification interface
to the HTTP API.

Functional changes compared to rcouch:

 - make _db_updates an admin-only resource

Docs:

 - updated api/misc to include basic info on `/_db_updates`

License:

  Apache 2 license, updated LICENSE.

Notice:

  (c) 2012 Benoit Chesneau, updated NOTICE.

Tests:

 - only manual testing of the various API differences due to
   complications with asynchronous HTTP requests in the JS
   test suite and total annoyance of overly complicated
   ibrowse/httpc modules for writing etap tests.

Recommendation to ship this as EXPERIMENTAL until we have tests.
7 files changed
tree: dd60852cfaf0ed4bd57f13bfc986ebde2ed0bf21
  1. src/
  2. LICENSE
  3. Makefile.am
  4. NOTICE
  5. README.md
README.md

couch_dbupdates

couch_dbupdates is a simple couchdb modules to receive databases events in couchdb node.

It's actually supported by all the refuge projects:

HTTP API

To get db events, do a GET to /_db_updates .

You can pass an optional query parameters:

  • feed The feed can be longpoll (default) for longpolling, eventsource for event stream or continuous for continuous feed.
  • timeout: timeout before the longpolling connection close or when the heartbeat is emitted.
  • heartbeat: true, or false. an empty line is emittend when the timeout occurs to maintain the connection active.

Example of usage

$ curl http://127.0.0.1:5984/_db_updates?feed=continuous
{"type":"created","db_name":"testdb"}
{"type":"updated","db_name":"testdb"}
{"type":"deleted","db_name":"testdb"}