class
CouchDB::Replication::Replicator
- CouchDB::Replication::Replicator
- Reference
- Object
Overview
Implements the 7-step CouchDB replication protocol between two adapters.
Replication is resumable: a Checkpoint document is written to both source
and target after every batch of BATCH_SIZE (100) documents so that an
interrupted run can continue from where it left off.
Steps per batch:
- Verify peers (fetch
infofrom source and target) - Read checkpoint (determine
sincesequence) - Fetch changes feed from source
- Call
revs_diffon target to find missing revisions - Fetch missing documents from source via
bulk_get - Write documents to target via
bulk_docs(new_edits: false) - Write checkpoint to both source and target
Defined in:
couchdb/replication/replicator.crConstructors
-
.new(source : Adapter, target : Adapter, doc_ids : Array(String) | Nil = nil, filter : Proc(Document, Bool) | Nil = nil, checkpoint_store : Adapter | Nil = nil)
Creates a replicator that will copy documents from source to target.
Instance Method Summary
-
#replicate : Session
Runs the full replication loop and returns a
Sessionwith transfer statistics.
Constructor Detail
Creates a replicator that will copy documents from source to target.
doc_ids limits replication to a specific set of document IDs (applied
before revs_diff to avoid unnecessary network calls).
filter is an arbitrary predicate applied after bulk_get; only documents
for which it returns true are written to the target.
Both options are composable: set both to filter by ID and by content.
Instance Method Detail
Runs the full replication loop and returns a Session with transfer statistics.
The loop continues until the changes feed returns fewer results than
BATCH_SIZE, indicating that all pending changes have been transferred.
On error, returns a failed Session with the exception message in error.