Packages
reckon_db
2.3.4
5.11.0
5.10.4
5.10.3
5.10.1
5.10.0
5.9.1
5.9.0
5.8.3
5.8.2
5.8.1
5.8.0
5.7.0
5.6.1
5.6.0
5.5.5
5.5.4
5.5.3
5.5.2
5.5.1
5.5.0
5.4.0
5.2.2
5.2.1
5.2.0
5.1.0
5.0.0
4.0.0
3.1.2
3.1.1
3.0.0
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.1
2.3.0
2.2.2
2.2.0
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.0
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.3
1.6.2
1.6.1
1.6.0
1.5.1
1.5.0
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0
BEAM-native Event Store built on Khepri/Ra with Raft consensus. Event sourcing, persistent subscriptions, snapshots, and automatic cluster formation via UDP multicast discovery. Ships embedded Rust NIFs for 3-15x acceleration of crypto, hashing, compression, aggregation, filter matching, and grap...
Current section
Files
Jump to
Current section
Files
src/reckon_db_snapshot_backend.erl
%% @doc Behaviour for pluggable snapshot backends.
%%
%% Aggregate snapshots are a COLD PATH — written periodically by evoq's
%% `maybe_snapshot/1' trigger, read only during aggregate rehydration.
%% Not the bottleneck that drove the log-backend split, but equally
%% worth isolating so a backend can specialise (e.g., a RocksDB log
%% backend could either reuse its column families for snapshots, or
%% delegate to the Khepri control plane).
%%
%% The default implementation (`reckon_db_khepri_snapshot_backend')
%% stores snapshots in Khepri — completely fine for cold-path use.
%% Alternative implementations exist primarily to avoid the Khepri
%% dependency when a backend wants to be self-contained.
%%
%% @author rgfaber
-module(reckon_db_snapshot_backend).
-type state() :: term().
-type source_id() :: binary(). %% aggregate id
-type stream_id() :: binary().
-type version() :: non_neg_integer().
-type snapshot_data() :: map() | binary().
-export_type([state/0, source_id/0, stream_id/0, version/0, snapshot_data/0]).
-callback init(Opts :: map()) ->
{ok, state()} | {error, term()}.
-callback close(state()) -> ok.
-callback save(state(), source_id(), stream_id(), version(), snapshot_data()) ->
ok | {error, term()}.
-callback load(state(), source_id(), stream_id()) ->
{ok, #{version := version(), data := snapshot_data()}}
| {error, not_found}
| {error, term()}.
-callback load_at(state(), source_id(), stream_id(), version()) ->
{ok, snapshot_data()} | {error, not_found} | {error, term()}.
-callback delete(state(), source_id(), stream_id()) ->
ok | {error, term()}.
-callback list(state(), stream_id()) ->
{ok, [#{version := version(), source_id := source_id()}]}
| {error, term()}.
-callback exists(state(), source_id(), stream_id()) -> boolean().