barrel_design_catalog (barrel_design v0.1.0)

View Source

Installed designs and their module bytes, kept as local documents of the source database: persisted and backed up with it, never replicated, and never part of its changes feed, so no map sees them.

Summary

Functions

A local uninstall: no design, the mark stays.

The designs a database runs: every name whose record holds one.

Whether the database has a catalog entry or a publication record: the two things that make barrel_design follow it.

Whether any publication record exists, deleted winners included: a live signed version can sit behind a deleted one.

A local install: the record keeps its mark and provenance.

Write a name's record durably: it is the commit point of an install, an acceptance or a withdrawal.

One name's record: its design (or none), origin (local or published), the accepted mark (#{version, action, manifest} or none), the provenance of a published one (#{statement_id, payload_digest, key_id, source_db, name} or none) and its status. The document is never deleted, so a mark outlives an uninstall or a withdrawal. A record written before marks existed is a local install.

Functions

delete_design(Db, Name)

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

A local uninstall: no design, the mark stays.

delete_module(Db, Digest)

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

design(Db, Name)

-spec design(binary(), binary()) -> {ok, map()} | {error, not_found}.

designs(Db)

-spec designs(binary()) -> {ok, #{binary() => map()}} | {error, term()}.

The designs a database runs: every name whose record holds one.

has_designs(Db)

-spec has_designs(binary()) -> boolean().

Whether the database has a catalog entry or a publication record: the two things that make barrel_design follow it.

has_statements(Db)

-spec has_statements(binary()) -> boolean().

Whether any publication record exists, deleted winners included: a live signed version can sit behind a deleted one.

module_bytes(Db, Digest)

-spec module_bytes(binary(), binary()) -> {ok, binary()} | {error, not_found}.

modules(Db)

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

put_design(Db, Design)

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

A local install: the record keeps its mark and provenance.

put_module(Db, Digest, Bytes)

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

put_record(Db, Name, _)

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

Write a name's record durably: it is the commit point of an install, an acceptance or a withdrawal.

record(Db, Name)

-spec record(binary(), binary()) -> {ok, map()} | not_found.

One name's record: its design (or none), origin (local or published), the accepted mark (#{version, action, manifest} or none), the provenance of a published one (#{statement_id, payload_digest, key_id, source_db, name} or none) and its status. The document is never deleted, so a mark outlives an uninstall or a withdrawal. A record written before marks existed is a local install.

records(Db)

-spec records(binary()) -> {ok, #{binary() => map()}} | {error, term()}.