Appends and queries events in a Chronicle event log.
The event log is the primary EventSequence in Chronicle. Use append/3 to
record domain events for a given event source (such as an aggregate root).
Usage
:ok = Chronicle.EventLog.append("account-1", %MyApp.Events.AccountOpened{
account_id: "account-1",
owner_name: "Alice",
initial_balance: 500
})To append to a specific client:
:ok = Chronicle.EventLog.append("account-1", event, client: :my_chronicle)Multiple events
events = [
%MyApp.Events.AccountOpened{account_id: "1", owner_name: "Alice"},
%MyApp.Events.FundsDeposited{account_id: "1", amount: 500}
]
:ok = Chronicle.EventLog.append_many("account-1", events)
Summary
Functions
Appends a single event to the event log for the given event source.
Appends multiple events to the event log for the given event source.
Returns events for the given event source ID from the event log.
Functions
Appends a single event to the event log for the given event source.
Options
:client— the client name (default:Chronicle.Client):namespace— overrides the client's default namespace:event_source_type— the event source type (default:""):event_stream_type— the event stream type (default:""):event_stream_id— the event stream ID (default:""):tags— list of tag strings:subject— the identity subject string
Returns :ok on success or {:error, reason} on failure.
Appends multiple events to the event log for the given event source.
All events are appended atomically. Each event must be a struct that
use Chronicle.EventType.
Options
Same as append/3.
Returns events for the given event source ID from the event log.
Options
:client— the client name (default:Chronicle.Client):namespace— overrides the client's default namespace:event_types— list of event type modules to filter by (default: all)
Returns {:ok, [appended_event]} or {:error, reason}.