barrel_att_store (barrel_docdb v1.2.0)
View SourceAttachment 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 blob, the RocksDB BlobDB backend) via backend_module/1, resolved to a module and tagged into the returned att_ref. Streaming handles embed their att_ref, so streaming calls dispatch to the same backend.
Backends can be optional sibling apps (e.g. barrel_att_s3, kept out of the default embeddable build so it doesn't pull in livery_s3/livery); is_available/1 probes for one at runtime via code:ensure_loaded/1, the same pattern barrel_vectordb_index uses for the optional FAISS backend, so open/2 fails cleanly with {error, {backend_unavailable, _}} rather than crashing on an unloaded module.
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
Functions
Attachment feed entries since an HLC (exclusive).
Resolve a symbolic backend name to its implementation module. A bare module atom (not blob/s3) passes through unchanged, for back-compat with any caller that already names a module directly.
Hard-link snapshot of the attachment store into Path (timeline forks). {error, unsupported} for backends without it.
Delete with options (origin_hlc for replicated deletes).
Erase anything the backend owns beyond its local directory (e.g. S3 objects). {error, unsupported} for backends without it -- callers (delete_db) treat that as nothing extra to do.
Whether a backend's implementation is present in the build. blob ships with barrel_docdb itself; other backends are optional sibling apps (opted into the build via their own rebar profile) probed for at runtime, same pattern as barrel_vectordb_index:is_available/1 for the optional FAISS backend.
Whether this database's backend supports attachment sync.
Types
Functions
-spec abort_stream(att_stream()) -> ok.
Attachment feed entries since an HLC (exclusive).
Resolve a symbolic backend name to its implementation module. A bare module atom (not blob/s3) passes through unchanged, for back-compat with any caller that already names a module directly.
Hard-link snapshot of the attachment store into Path (timeline forks). {error, unsupported} for backends without it.
-spec close(att_ref()) -> ok.
-spec close_stream(att_stream()) -> ok.
Delete with options (origin_hlc for replicated deletes).
Erase anything the backend owns beyond its local directory (e.g. S3 objects). {error, unsupported} for backends without it -- callers (delete_db) treat that as nothing extra to do.
-spec finish_stream(att_stream()) -> {ok, map()} | {ok, ignored} | {error, term()}.
Whether a backend's implementation is present in the build. blob ships with barrel_docdb itself; other backends are optional sibling apps (opted into the build via their own rebar profile) probed for at runtime, same pattern as barrel_vectordb_index:is_available/1 for the optional FAISS backend.
-spec read_chunk(att_stream()) -> {ok, binary(), att_stream()} | eof | {error, term()}.
Whether this database's backend supports attachment sync.
-spec write_chunk(att_stream(), binary()) -> {ok, att_stream()} | {error, term()}.