barrel_att_store (barrel_docdb v1.0.0)

View Source

Attachment store dispatcher.

Selects an attachment backend (a barrel_att_backend) per database and routes all attachment calls to it. The backend is chosen from att_opts.backend at open/2 (default barrel_att_store_blob, the RocksDB BlobDB backend) and tagged into the returned att_ref. Streaming handles embed their att_ref, so streaming calls dispatch to the same backend.

Callers (barrel_att, barrel_docdb, barrel_db_server) keep using this module; the backend split is transparent to them. This dispatcher is also the single keyspace choke point: every DbName resolves here, so backends always build blob and att-feed keys with the keyspace.

Summary

Types

att_ref/0

-type att_ref() :: #{backend => module(), _ => _}.

att_stream/0

-type att_stream() :: #{att_ref := att_ref(), _ => _}.

Functions

abort_stream(Stream)

-spec abort_stream(att_stream()) -> ok.

att_changes(AttRef, DbName, Since, Opts)

-spec att_changes(att_ref(), binary(), term(), map()) -> {ok, [map()], term()} | {error, term()}.

Attachment feed entries since an HLC (exclusive).

att_floor(AttRef, DbName)

-spec att_floor(att_ref(), binary()) -> term() | undefined.

checkpoint(AttRef, Path)

-spec checkpoint(att_ref(), string()) -> ok | {error, term()}.

Hard-link snapshot of the attachment store into Path (timeline forks). {error, unsupported} for backends without it.

close(AttRef)

-spec close(att_ref()) -> ok.

close_stream(Stream)

-spec close_stream(att_stream()) -> ok.

delete(AttRef, DbName, DocId, AttName)

-spec delete(att_ref(), binary(), binary(), binary()) -> ok | {error, term()}.

delete(AttRef, DbName, DocId, AttName, Opts)

-spec delete(att_ref(), binary(), binary(), binary(), map()) -> ok | {error, term()}.

Delete with options (origin_hlc for replicated deletes).

delete_all(AttRef, DbName, DocId)

-spec delete_all(att_ref(), binary(), binary()) -> ok | {error, term()}.

finish_stream(Stream)

-spec finish_stream(att_stream()) -> {ok, map()} | {ok, ignored} | {error, term()}.

fold(AttRef, DbName, DocId, Fun, Acc)

-spec fold(att_ref(), binary(), binary(), fun(), term()) -> term().

get(AttRef, DbName, DocId, AttName)

-spec get(att_ref(), binary(), binary(), binary()) -> {ok, binary()} | not_found | {error, term()}.

get_info(AttRef, DbName, DocId, AttName)

-spec get_info(att_ref(), binary(), binary(), binary()) -> {ok, map()} | {error, term()}.

get_stream(AttRef, DbName, DocId, AttName)

-spec get_stream(att_ref(), binary(), binary(), binary()) -> {ok, att_stream()} | {error, term()}.

open(Path, Options)

-spec open(string(), map()) -> {ok, att_ref()} | {error, term()}.

put(AttRef, DbName, DocId, AttName, Data)

-spec put(att_ref(), binary(), binary(), binary(), binary()) -> {ok, map()} | {error, term()}.

put(AttRef, DbName, DocId, AttName, Data, Opts)

-spec put(att_ref(), binary(), binary(), binary(), binary(), map()) -> {ok, map()} | {error, term()}.

put_stream(AttRef, DbName, DocId, AttName, ContentType)

-spec put_stream(att_ref(), binary(), binary(), binary(), binary()) ->
                    {ok, att_stream()} | {error, term()}.

put_stream(AttRef, DbName, DocId, AttName, ContentType, Opts)

-spec put_stream(att_ref(), binary(), binary(), binary(), binary(), map()) ->
                    {ok, att_stream()} | {error, term()}.

read_chunk(Stream)

-spec read_chunk(att_stream()) -> {ok, binary(), att_stream()} | eof | {error, term()}.

rebuild_feed(AttRef, DbName)

-spec rebuild_feed(att_ref(), binary()) -> {ok, map()} | {error, term()}.

supports_sync(AttRef)

-spec supports_sync(att_ref()) -> boolean().

Whether this database's backend supports attachment sync.

sweep_att_feed(AttRef, DbName, Cutoff)

-spec sweep_att_feed(att_ref(), binary(), term()) -> {ok, map()} | {error, term()}.

write_chunk(Stream, Data)

-spec write_chunk(att_stream(), binary()) -> {ok, att_stream()} | {error, term()}.