class CouchDB::Replication::Session

Overview

Result object returned by Database#replicate_to, #replicate_from, and #sync.

Carries transfer statistics for one replication run. Check ok first; if it is false, #error contains the failure message.

session = local.replicate_to(remote)
puts session.ok?          # true / false
puts session.docs_written # number of documents transferred
puts session.last_seq     # last sequence number processed

Defined in:

couchdb/replication/session.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(source_url : String, target_url : String) #

Creates a new session for a replication from source_url to target_url. All counters start at zero and ok starts as false until #finish! is called.


[View source]

Instance Method Detail

def doc_write_failures : Int32 #

Total number of documents that failed to write to the target.


[View source]
def docs_read : Int32 #

Total number of documents fetched from the source.


[View source]
def docs_written : Int32 #

Total number of documents successfully written to the target.


[View source]
def error : String | Nil #

Error message when ok is false; nil on success.


[View source]
def fail!(message : String) #

Records an error message and marks the session as failed.


[View source]
def finish! #

Marks the session as successful. Called by Replicator after all batches complete.


[View source]
def last_seq : String #

Last sequence number processed by this replication run.


[View source]
def ok? : Bool #

true when replication completed without error, false otherwise.


[View source]
def record_batch(read : Int32, written : Int32, failures : Int32, seq : String) #

Accumulates statistics from one replication batch. Called by Replicator after each batch of documents is processed.


[View source]
def source_url : String #

Name or URL of the replication source.


[View source]
def target_url : String #

Name or URL of the replication target.


[View source]
def to_s(io : IO) #

Returns a human-readable summary of the replication session.


[View source]