Fork me on GitHub

It is possible to be notified about changes that occur in CouchDB databases.

In Sohva, change stream is implemented using akka streams. Once materialized, the streams provided by Sohva can return a UniqueKillSwitch to close the streams.

Database updates

Given a CouchClient or a session, you can be notified about updates in databases

      val stream = couch.dbUpdates()

    

you can provide a timeout and a heartbeat to this method.

Database changes

A more interesting change stream is the one on databases, allowing to be notified about all document updates.

      val stream = db.changes.stream()
// print on stdout all the events
val killSwitch = stream.toMat(Sink.foreach(println _))(Keep.left).run()
// wait a while and close the stream
killSwitch.shutdown()

    

This method takes several parameters to reflect the underlying CouchDB API, refer to the documentation for details.