barrel_rep_att (barrel_docdb v1.0.0)

View Source

The attachment phase of a replication run. Runs AFTER the doc loop (independent lifecycles, independent checkpoint): fold the source's attachment feed since the attachment checkpoint, digest-diff each batch against the target in one round trip, stream the missing blobs (digest-verified at the target's commit point), apply LWW-guarded deletes, checkpoint per batch.

Degrades to skipped when either transport (or the underlying attachment backend) has no feed support. Redelivery is safe end-to-end: digest diff answers have, and the origin-HLC guard turns replays into {ok, ignored}.

Summary

Functions

Run the attachment phase from an explicit since with a caller-supplied checkpoint fun (invoked with the last visited feed HLC after each batch, and once more on completion). This is the timeline merge entry point; sync/5 wraps it with the replication-checkpoint machinery.

Types

att_info/0

-type att_info() ::
          #{name := binary(),
            content_type := binary(),
            length := non_neg_integer(),
            digest := binary(),
            chunked => boolean(),
            chunk_size => pos_integer(),
            chunk_count => pos_integer()}.

change/0

-type change() :: map().

db_config/0

-type db_config() :: #{path => string(), store => module(), atom() => term()}.

db_name/0

-type db_name() :: binary().

db_ref/0

-type db_ref() :: pid() | atom().

doc/0

-type doc() :: #{binary() => term()}.

doc_info/0

-type doc_info() :: #{id := docid(), rev := revid(), deleted := boolean(), revtree := revtree()}.

docid/0

-type docid() :: binary().

endpoint/0

-type endpoint() :: db_name() | {node(), db_name()} | {module(), term()}.

rep_options/0

-type rep_options() ::
          #{continuous => boolean(),
            since => seq_string(),
            filter => fun((doc()) -> boolean()),
            atom() => term()}.

rev_info/0

-type rev_info() ::
          #{id := revid(),
            parent := revid() | undefined,
            deleted := boolean(),
            attachments => #{binary() => att_info()}}.

revid/0

-type revid() :: binary().

revtree/0

-type revtree() :: #{revid() => rev_info()}.

seq/0

-type seq() :: barrel_hlc:timestamp().

seq_string/0

-type seq_string() :: binary().

view_name/0

-type view_name() :: binary().

view_result/0

-type view_result() :: #{key := term(), value := term(), id := docid()}.

Functions

sync(Source, Target, SourceTransport, TargetTransport, Opts)

-spec sync(term(), term(), module(), module(), map()) -> {ok, map()} | skipped | {error, term()}.

sync_from(Source, Target, SourceTransport, TargetTransport, Since, CheckpointFun, Opts)

-spec sync_from(term(),
                term(),
                module(),
                module(),
                barrel_hlc:timestamp() | first,
                fun((barrel_hlc:timestamp() | first) -> ok),
                map()) ->
                   {ok, map()} | skipped | {error, term()}.

Run the attachment phase from an explicit since with a caller-supplied checkpoint fun (invoked with the last visited feed HLC after each batch, and once more on completion). This is the timeline merge entry point; sync/5 wraps it with the replication-checkpoint machinery.