barrel_rep_transport behaviour (barrel_docdb v1.1.1)
View Sourcebarrel_rep_transport - Transport behaviour for replication
This behaviour defines the interface for the version-vector replication protocol. Transports abstract the communication with databases, allowing replication to work between local databases or remote ones.
The protocol per batch of changes:
get_changes/3on the source (each change carries the doc's current version token asrev).diff_versions/2on the target with#{DocId => Token}: the target answershavewhen its version vector already covers the offered version,missingotherwise.- For each missing doc:
get_doc/3on the source returns the current body plus#{version, vv, deleted}, thenput_version/5applies it on the target, which fast-forwards, ignores (already covered), or records a conflict sibling with a deterministic last-write-wins winner.
Local documents carry replication checkpoints and are not replicated themselves.
Summary
Types
-type att_info() :: #{name := binary(), content_type := binary(), length := non_neg_integer(), digest := binary(), chunked => boolean(), chunk_size => pos_integer(), chunk_count => pos_integer()}.
-type change() :: map().
-type db_name() :: binary().
-type docid() :: binary().
-type revid() :: binary().
-type seq() :: barrel_hlc:timestamp().
-type seq_string() :: binary().
-type view_name() :: binary().
Callbacks
-callback sync_hlc(Endpoint :: term(), Hlc :: barrel_hlc:timestamp()) -> {ok, barrel_hlc:timestamp()} | {error, term()}.