apache / nano

Nano is now part of Apache CouchDB. Repo moved to https://GitHub.com/apache/couchdb-nano
https://github.com/apache/couchdb-nano
Other
1.13k stars 157 forks source link

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

Open carlosduclos opened 7 years ago

carlosduclos commented 7 years ago

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

carlosduclos commented 7 years ago

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.

carlosduclos commented 7 years ago

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:

carlosduclos commented 7 years ago

Sent pull request #350