A deterministic couchdb replication watcher.
Overwatch is an
EventEmitter that emits events reflecting various states of
the couches it watches. It has a fairly simple api that allows you to easily
watch and monitor
Please note that we currently make the assumption that these databases are already replicating and we are just monitoring that this assumption is true.
The design here is based around a hub-and-spoke concept of replication. This
means that we take one
hub couch and allow
n number of
spokes that all
replicate through the
hub couch. This prevents redundant replication and makes
the replication model much simpler.
followers are the data structure of
follow feeds that are used
to monitor the changes feeds of each couchdb that you would like. The various
databases are correctly associated with the feeds for all of the couches being
monitored. This allows us to set proper
The follow feeds have two states,
bufferChange state allows us to buffer all of the past changes from CouchDB to
be re-emitted when we want to process them. The timing for processing is key here as
we do not want to begin processing until ALL couches at a particular database
our caught up on their changes. When this occurs, we perform a full audit of the
couches for that database and begin setting fulfillments.
overwatch has this concept of
fulfillments which is a timer that is set
for each time we receive a new
change event from
follow. Since we are
listening on multiple couch
_changes feeds to ensure replication is occurring,
we need a way to determinsitically evaluate that this occured. If two CouchDBs
are assumed to be replicating their
foo databases, if we receive a change on
one and not the other (with some extra checking involved),
CouchDB has failed to fulfill its promise to us. This is
where we emit the
unfulfilled event for you to take action on this!
var overwatch = ;var watcher =;//// Listen on some events with your own functions//watcher;//// We are now listening on live changes for all feeds for this database//watcher;//// Log some events when we process each change for each couch and database//watcher;//// Oh gosh couch failed to fulfill its promise to replicate :'(.// Bad couchdb//watcher;//// Emits when we are listening on live changes for a particular couch and// database. It is a proxy of `follow`s catchup event and is just a signal of// progress in the initialization. We may still be buffering events if this is// not the last database to catchup//watcher;
If you don't want to filter off of a call to
_all_dbs on the
hub couch, we
also support specifying the
dbs in an array directly!
Note: The dbs still need to exist or
follow will be very unhappy with you
var Overwatch = ;//// Remark: subtle note that we support calling with or without `new`//var watcher =couches:url: '' hub: trueurl: ''dbs: 'foo' 'bar' 'baz';watcher;