barrel_rep_transport_http (barrel_docdb v1.1.1)

View Source

The network replication transport: barrel_rep_transport over HTTP (hackney), speaking the /db/:db/_sync/* wire served by barrel_server_sync.

The endpoint term is a normalized map built by endpoint/1; the normalized URL alone feeds the replication id (rep_id_term/1), so credentials and tuning never invalidate checkpoints. Every request carries an x-barrel-hlc header and folds the response header back into the local clock (passive coupling on top of the explicit sync_hlc exchange).

Auth: auth => #{token => Bin} on the endpoint, else the app env {barrel_docdb, sync_auth, #{Origin => Token}} keyed by <<"scheme://host:port">> (no secrets in persisted task configs).

Summary

Types

endpoint/0

-type endpoint() ::
          #{url := binary(),
            auth => #{token := binary()},
            signing => #{key_id := binary(), priv_key := binary()},
            ssl_options => [term()],
            pool => atom(),
            connect_timeout => pos_integer(),
            recv_timeout => pos_integer(),
            headers => [{binary(), binary()}]}.

Functions

att_changes(Endpoint, Since, Opts)

db_info(Endpoint)

delete_attachment(Endpoint, DocId, Name, Meta)

delete_local_doc(Endpoint, DocId)

diff_attachments(Endpoint, Entries)

diff_versions(Endpoint, TokenMap)

endpoint(Map)

-spec endpoint(binary() | string() | map()) -> endpoint().

Build a normalized endpoint from a URL (or a map carrying one). Normalization matters: the URL is the replication identity, so scheme/host lowercase and no trailing slash keep checkpoints stable across config reformatting.

get_attachment_stream(Endpoint, DocId, Name)

get_changes(Endpoint, Since, Opts)

get_doc(Endpoint, DocId, Opts)

get_local_doc(Endpoint, DocId)

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

put_local_doc(Endpoint, DocId, Doc)

put_version(Endpoint, Doc, Token, VVBin, Deleted)

rep_id_term(_)

The replication identity of this endpoint: the normalized URL only (credentials and tuning excluded).

sync_hlc(Endpoint, Hlc)