class
CouchDB::Replication::Checkpoint
- CouchDB::Replication::Checkpoint
- Reference
- Object
Overview
Manages resumable replication checkpoints stored as _local/ documents.
A checkpoint records the last sequence number successfully replicated. When a replication run is interrupted, the next run reads the checkpoint and resumes from where the previous run left off rather than reprocessing the entire changes feed.
By default checkpoints are stored on both the source and the target adapter. The starting sequence is the minimum of the two checkpoints so that neither side can get ahead of the other.
When a store adapter is provided, checkpoints are read from and written to that single adapter only (typically the remote). This is the PouchDB pattern: the remote retains the checkpoint, so a deleted/recreated local store resumes replication without a full resync.
Defined in:
couchdb/replication/checkpoint.crConstant Summary
-
CHECKPOINT_PREFIX =
"_local/"
Constructors
-
.new(source : Adapter, target : Adapter, store : Adapter | Nil = nil)
Creates a checkpoint manager for the given source and target adapters.
Instance Method Summary
-
#read : String
Returns the sequence number to start from for this replication.
-
#write(seq : String)
Writes seq as the new checkpoint.
Constructor Detail
Creates a checkpoint manager for the given source and target adapters. The checkpoint document ID is derived from the MD5 of both database names, giving a stable, collision-resistant identifier for this replication pair.
Pass store to pin checkpoint reads and writes to a single adapter.
Instance Method Detail
Returns the sequence number to start from for this replication.
When a store adapter was given, reads only from that adapter.
Otherwise reads from both source and target and returns the minimum,
ensuring that neither side can skip changes the other has not yet seen.
Returns "0" when no checkpoint exists.
Writes seq as the new checkpoint.
When a store adapter was given, writes only to that adapter.
Otherwise writes to both source and target.
Called by Replicator after each successfully processed batch.