barrel_rep_transport_local (barrel_docdb v1.1.1)

View Source

barrel_rep_transport_local - Local transport for replication

Transport implementation for replicating between databases in the same Erlang VM. The endpoint is simply the database name.

Summary

Functions

Get database info

Delete a local document

Which offered versions is this database missing?

Get changes since a sequence

Get a document for replication (tombstones included) with its version protocol metadata.

Get a local document

Put a local document

Synchronize local HLC with remote timestamp This ensures the local clock reflects causality with remote events. Note: HLC is global to the node, not per-database.

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

att_changes(DbName, Since, Opts)

db_info(DbName)

-spec db_info(db_name()) -> {ok, map()} | {error, term()}.

Get database info

delete_attachment(DbName, DocId, Name, Meta)

delete_local_doc(DbName, DocId)

-spec delete_local_doc(db_name(), docid()) -> ok | {error, not_found} | {error, term()}.

Delete a local document

diff_attachments(DbName, Entries)

diff_versions(DbName, TokenMap)

-spec diff_versions(db_name(), #{docid() => binary()}) ->
                       {ok, #{docid() => missing | have}} | {error, term()}.

Which offered versions is this database missing?

get_attachment_stream(DbName, DocId, Name)

get_changes(DbName, Since, Opts)

-spec get_changes(db_name(), seq() | first, map()) -> {ok, [map()], seq()} | {error, term()}.

Get changes since a sequence

get_doc(DbName, DocId, Opts)

-spec get_doc(db_name(), docid(), map()) -> {ok, map(), map()} | {error, not_found} | {error, term()}.

Get a document for replication (tombstones included) with its version protocol metadata.

get_local_doc(DbName, DocId)

-spec get_local_doc(db_name(), docid()) -> {ok, map()} | {error, not_found} | {error, term()}.

Get a local document

put_attachment(DbName, DocId, Name, Meta, ReadFun)

put_local_doc(DbName, DocId, Doc)

-spec put_local_doc(db_name(), docid(), map()) -> ok | {error, term()}.

Put a local document

put_version(DbName, Doc, VersionToken, VVBin, Deleted)

-spec put_version(db_name(), map(), binary(), binary(), boolean()) ->
                     {ok, docid(), binary()} | {error, term()}.

Apply a replicated version.

sync_hlc(DbName, RemoteHlc)

-spec sync_hlc(db_name(), barrel_hlc:timestamp()) -> {ok, barrel_hlc:timestamp()} | {error, term()}.

Synchronize local HLC with remote timestamp This ensures the local clock reflects causality with remote events. Note: HLC is global to the node, not per-database.