Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
CouchDB provides a change notification API (called _changes) that allows clients a great deal of
flexibility in defining how to react in response to data flows.
Briefly, _changes works like
so:
An HTTP connection is opened to the _changes URL for the CouchDB database of
interest.
Wait. When any change occurs in the database in question (any document creation, deletion, or update), a JSON map is sent to the client describing the affected document ID and revision.
If you have elected to be notified of changes continuously, repeat from 2.
The simplest of all _changes
usage via Clojure might be using Clutch’s watch-changes function to echo all change
notifications to *out*. Here, we’ll
create a new database for our _changes
experimentation, set up a Clutch watch function for that database, and add
a few documents to see what happens: