Chronik v0.1.1 Chronik.Store.Adapters.ETS View Source
This module is an adapter for the Store based on ETS tables.
Link to this section Summary
Functions
Append a list of events to the Store
This function allows the Projection module to comapre versions of EventRecords coming form the PubSub bus. The implementation depends on the version type but a trivial implementation is to compare the integers and return the corresponding atoms
Retrieves all events from the store starting (but not including) at version
Retrieves all events from the store for a given aggregate starting
(but not including) at version
Retrives a snapshot from the Store. If there is no snapshot it returns
nil
. If there is a snapshot this function should return a tuple
{version, state}
indicating the state of the snapshot and with
wich version of the aggregate was created
This function creates a snapshot in the store for the given aggregate
.
The Store only stores the last snapshot
Link to this section Functions
Append a list of events to the Store.
aggregate
is the agregate that generated the events.
events
is an enumberable with the events to append.
options
is a keyword indicating the optimistic concurrency checks
to perform at the moment of writing to the stream.
Versioning
Possible values are:
:any
: (default value) no checks are performed, the events are always written:no_stream
: verifies that the target stream does not exists yetany other integer value: the event number expected to currently be at
The return values are {:ok, last_inserted_version, records}
on success or
{:error, message}
in case of failure.
Callback implementation for Chronik.Store.append/3
.
This function allows the Projection module to comapre versions of EventRecords coming form the PubSub bus. The implementation depends on the version type but a trivial implementation is to compare the integers and return the corresponding atoms.
Callback implementation for Chronik.Store.compare_version/2
.
Retrieves all events from the store starting (but not including) at version
.
Possible version
values are :all
(default value) or a term
indicating starting read position. Event at version
is not included
in the result.
The return values are {:ok, version, [event records]}
or {:error, message}
in case of failure.
If no records are found on the stream (starting at version)
the function returns {:ok, version, []}
.
Callback implementation for Chronik.Store.fetch/1
.
Retrieves all events from the store for a given aggregate starting
(but not including) at version
.
Possible version
values are :all
(default value) or a term
indicating starting read position. Event at version
is not included
in the result.
The return values are {:ok, version, [event records]}
or {:error, message}
in case of failure.
If no records are found on the stream (starting at version)
the function returns {:ok, version, []}
.
Callback implementation for Chronik.Store.fetch_by_aggregate/2
.
Retrives a snapshot from the Store. If there is no snapshot it returns
nil
. If there is a snapshot this function should return a tuple
{version, state}
indicating the state of the snapshot and with
wich version of the aggregate was created.
Callback implementation for Chronik.Store.get_snapshot/1
.
This function creates a snapshot in the store for the given aggregate
.
The Store only stores the last snapshot.
Callback implementation for Chronik.Store.snapshot/3
.