Maestro v0.3.1 Maestro.Store View Source
Concise API for events and snapshots.
If you are using the Maestro.Store.Postgres
adapter, an Ecto.Repo
should
be provided.
Link to this section Summary
Functions
Commit the events and apply all projections within a transaction. If there's a sequence number conflict, the events and projections will be discarded such that the command generating these components could be retried.
Commit the events provided iff there is no sequence number conflict. Otherwise, the command should be retried as indicated by the specific error tuple.
Store the snapshot iff the sequence number is greater than what is in the store. This allows nodes that are partitioned from each other to treat the store as the source of truth even when writing snapshots.
Retrieve all events for a specific aggregate by id and minimum sequence number.
Retrieve a snapshot by aggregate id and minimum sequence number. If no snapshot is found, nil is returned.
Return the maximum allowable sequence number permitted by the durable storage adapter.
Link to this section Types
event()
View Source
event() :: Maestro.Types.Event.t()
event() :: Maestro.Types.Event.t()
events()
View Source
events() :: [event()]
events() :: [event()]
id()
View Source
id() :: HLClock.Timestamp.t()
id() :: HLClock.Timestamp.t()
opts()
View Source
opts() :: [{:max_sequence, sequence()}]
opts() :: [{:max_sequence, sequence()}]
sequence()
View Source
sequence() :: non_neg_integer()
sequence() :: non_neg_integer()
snapshot()
View Source
snapshot() :: Maestro.Types.Snapshot.t()
snapshot() :: Maestro.Types.Snapshot.t()
Link to this section Functions
commit_all(events, projections) View Source
Commit the events and apply all projections within a transaction. If there's a sequence number conflict, the events and projections will be discarded such that the command generating these components could be retried.
commit_events(events)
View Source
commit_events(events()) :: :ok | {:error, :retry_command}
commit_events(events()) :: :ok | {:error, :retry_command}
Commit the events provided iff there is no sequence number conflict. Otherwise, the command should be retried as indicated by the specific error tuple.
commit_snapshot(snapshot)
View Source
commit_snapshot(snapshot()) :: :ok
commit_snapshot(snapshot()) :: :ok
Store the snapshot iff the sequence number is greater than what is in the store. This allows nodes that are partitioned from each other to treat the store as the source of truth even when writing snapshots.
get_events(aggregate_id, seq, opts \\ []) View Source
Retrieve all events for a specific aggregate by id and minimum sequence number.
Options include:
:max_sequence
- useful hydration purposes (defaults tomax_sequence/0
)
get_snapshot(aggregate_id, seq, opts \\ []) View Source
Retrieve a snapshot by aggregate id and minimum sequence number. If no snapshot is found, nil is returned.
Options include:
:max_sequence
- useful hydration purposes (defaults tomax_sequence/0
)
max_sequence()
View Source
max_sequence() :: non_neg_integer()
max_sequence() :: non_neg_integer()
Return the maximum allowable sequence number permitted by the durable storage adapter.