reckon_db_archive_backend behaviour (reckon_db v1.2.6)

View Source

Archive backend behaviour for reckon-db

Defines the interface for archive storage backends. Implementations can store archived events in various formats: - Local files - S3/object storage - Network storage

Summary

Functions

Generate a standard archive key.

Parse an archive key to extract metadata.

Callbacks

archive/3

-callback archive(State :: term(), ArchiveKey :: binary(), Events :: [event()]) ->
                     {ok, NewState :: term()} | {error, Reason :: term()}.

delete/2

-callback delete(State :: term(), ArchiveKey :: binary()) ->
                    {ok, NewState :: term()} | {error, Reason :: term()}.

exists/2

-callback exists(State :: term(), ArchiveKey :: binary()) -> {boolean(), NewState :: term()}.

init/1

-callback init(Opts :: map()) -> {ok, State :: term()} | {error, Reason :: term()}.

list/3

-callback list(State :: term(), StoreId :: atom(), StreamId :: binary()) ->
                  {ok, [binary()], NewState :: term()} | {error, Reason :: term()}.

read/2

-callback read(State :: term(), ArchiveKey :: binary()) ->
                  {ok, [event()], NewState :: term()} | {error, Reason :: term()}.

Functions

make_key(StoreId, StreamId, FromVersion, ToVersion)

-spec make_key(atom(), binary(), integer(), integer()) -> binary().

Generate a standard archive key.

parse_key(Key)

-spec parse_key(binary()) -> {ok, map()} | {error, invalid_key}.

Parse an archive key to extract metadata.