Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Let’s combine all of what we’ve learned about how to effectively use CouchDB from Clojure to implement an asynchronous work queue based on the events being emitted into the logging database we considered earlier. First, a refresher on what that data looks like:
Example 15-4. Sample event data
{:evt-type "auth/new-user" :username "Chas"}
{:evt-type "auth/new-user" :username "Dave"}
{:evt-type "sales/purchase" :username "Chas" :products ["widget1"]}
{:evt-type "sales/purchase" :username "Robin" :products ["widget14"]}
{:evt-type "sales/RFQ" :username "Robin" :budget 20000}
Now, you could add a single watch for changes in the
logging database, and instead of echoing those events
to *out*, do something useful with
them; that’s a perfectly valid thing to do, especially if your
requirements are relatively simple. However, most real-world systems need
some additional levers to pull to control event processing loads and more
ably support modular design requirements.