Skip to content

Instantly share code, notes, and snippets.

@ratopi
Last active January 13, 2017 22:10
Show Gist options
  • Save ratopi/226f61ddf4f444705395a0adbd774a6c to your computer and use it in GitHub Desktop.
Save ratopi/226f61ddf4f444705395a0adbd774a6c to your computer and use it in GitHub Desktop.
CouchDB Replication

couchdb replication

http://docs.couchdb.org/en/stable/replication/protocol.html

Query Changes

Initial GET /source/_changes?feed=normal&style=all_docs&heartbeat=10000

Continous GET /source/_changes?feed=continuous&style=all_docs&heartbeat=10000

Calculate Revision Difference

Ask for existing DOCs/REVs:

POST /target/_revs_diff HTTP/1.1

Delivers only missing DOCs/REVs.

Fetch Changed Documents

GET /source/SpaghettiWithMeatballs?revs=true&open_revs=[%225-00ecbbc%22,%221-917fa23%22,%223-6bcedf1%22]&latest=true

Response is Multipart containing all requested REVs. Missings Revs are indicated by Response 'Content-Type: application/json; error="true"' and content '{"missing":"3-6bcedf1"}'

Upload Batch of Changed Documents

POST /target/_bulk_docs

with

"new_edits": false

!

Upload Document with Attachments

PUT /target/SpaghettiWithMeatballs?new_edits=false

Sending multipart

Ensure In Commit

POST /target/_ensure_full_commit

Record Replication Checkpoint

PUT /source/_local/afa899a9e59589c3d4ce5668e3218aef

PUT /target/_local/afa899a9e59589c3d4ce5668e3218aef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment