Fact.Seam.Storage behaviour (Fact v0.2.1)
View SourceBehaviour defining the storage configuration for a Fact database.
This Fact.Seam implementation specifies the paths used by the system
for storing events, indices, ledgers, and locks. Implementations of this
behaviour allow different storage layouts, file structures, or storage
backends to be plugged in.
Responsibilities
path/2– Returns the root path of the database.records_path/3– Returns the path where event records are stored, or the path to a specific record.indices_path/2– Returns the path where index files are stored.ledger_path/2– Returns the path for the event ledger file(s).locks_path/2– Returns the path for lock files used for database concurrency.
Each function receives a configured instance (t()) and optional keyword
arguments, and should return either a valid Path.t() or an error tuple.
This allows the Fact system to operate on different storage strategies without changing the core database or event logic.
Summary
Callbacks
A callback function that gets the base path to the directory where all index files are stored.
A callback function that initializes the directory structure used for records, indexes, and any other files used by the database.
A callback function that gets the path to the directory containing the ledger file.
A callback function that gets the path to the directory containing the lock files.
A callback function that gets the path to configured root directory for the database.
A callback function that gets the directory containing all records, or the path to a specific record.
Types
@type t() :: struct()
Callbacks
@callback default_options() :: map()
@callback family() :: atom()
@callback id() :: {atom(), non_neg_integer()}
A callback function that gets the base path to the directory where all index files are stored.
A callback function that initializes the directory structure used for records, indexes, and any other files used by the database.
A callback function that gets the path to the directory containing the ledger file.
A callback function that gets the path to the directory containing the lock files.
A callback function that gets the path to configured root directory for the database.
@callback records_path(t(), record_id :: String.t(), opts :: keyword()) :: Path.t() | {:error, term()}
A callback function that gets the directory containing all records, or the path to a specific record.
@callback version() :: non_neg_integer()