apache / nano

Nano is now part of Apache CouchDB. Repo moved to https://GitHub.com/apache/couchdb-nano

Home Page:https://github.com/apache/couchdb-nano

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable permanent replication by writing to "_replicator" database instead of "_replicate" database.

carlosduclos opened this issue · comments

According to http://guide.couchdb.org/draft/replication.html (and own testing), writing a replication document to "_replicate" will enable replication only for the current server session, but after a server restart it will not enable it again.

Relates to #290

CouchDB developers in their infinite wisdom handle requests to "_replicator" differently from requests to "_replicate".

While requests to "_replicate" replied with a full response, requests to "_replicator" reply with a partial response and need to be polled until the replication is done. Working on implementing that.

After a few tries, I came to the conclusion that this requires at least two different methods. The reason is that replication will be scheduled after a write to "_replicator" and couchdb will handle the status internally. At some point in time the replication will finish (either successfully or with error), but there is no way to know when.

The idea behind this is to allow for a fully asynchronous API that can monitor the status of the replication without having to wait on it. This is especially important in large replication where the time involved in replication might be measured in several minutes, hours or even days!

So I have come up with three methods:

  • enableReplication: Starts the replication from a given db to a target db.
  • queryReplication: Queries the state of the replication at that time.
  • disableReplication: Stops the replication process.

Sent pull request #350