Raft v0.2.1 Raft.LogStore behaviour
The LogStore
module provides a behaviour and high-level api for interacting
with the underlying database engine. All values are encoded and decoded using
:erlang.term_to_binary
and :erlang.binary_to_term
before they’re stored.
Link to this section Summary
Functions
Closes the connection to the database
Deletes a range of logs inclusively
Used to destroy the data on disk. This is used for testing and development and is dangerous to run in production
Returns metadata and all the persisted logs. This is used for debugging and testing purposes only and should not be used in production
Gets a log at a specific index
Gets all metadata from the store
Determines if anything has been written to the log yet
Retrieves the last entry from the log. Returns :empty
if the log is empty
Retrieves the last index thats been saved to stable storage. If the database is empty then 0 is returned
Opens a new or existing database at the given path
Gets all logs from starting index to end index inclusive
Store logs in the log store and returns the last index
Stores the metadata
Link to this section Types
Link to this section Functions
Closes the connection to the database
Deletes a range of logs inclusively
Used to destroy the data on disk. This is used for testing and development and is dangerous to run in production.
Returns metadata and all the persisted logs. This is used for debugging and testing purposes only and should not be used in production.
get_entry(db(), index()) :: {:ok, Raft.Log.Entry.t()} | {:error, :not_found}
Gets a log at a specific index.
Gets all metadata from the store.
Determines if anything has been written to the log yet.
Retrieves the last entry from the log. Returns :empty
if the log is empty.
Retrieves the last index thats been saved to stable storage. If the database is empty then 0 is returned.
Opens a new or existing database at the given path.
Gets all logs from starting index to end index inclusive.
store_entries(db(), [Raft.Log.Entry.t()]) :: {:ok, index()}
Store logs in the log store and returns the last index.
Stores the metadata.
Link to this section Callbacks
get_entry(db(), key()) :: {:ok, encoded()} | {:error, :not_found}
get_metadata(db()) :: {:ok, encoded()} | {:error, :not_found}
store_entry(db(), key(), encoded()) :: :ok | {:error, any()}
store_metadata(db(), encoded()) :: :ok | {:error, any()}