Chronicle.EventSources.EventSource (cratis_chronicle v3.16.1)

Copy Markdown View Source

Declares an event source definition.

An event source gives appends a stable name, optional streams and default concurrency dimensions. Routing belongs to the append, not to event types: the same event type can be appended through different event sources.

defmodule MyApp.AccountEventSource do
  use Chronicle.EventSources.EventSource,
    name: "Account",
    description: "A bank account",
    concurrency: [:event_source_id]

  stream "Transactions",
    description: "Money movements",
    concurrency: [:event_source_id, :event_stream_id]
end

Definitions are discovered like event types and registered with the event store at startup. Append through one with the :event_source and :event_stream options of Chronicle.append/3 and friends. Without a definition appends behave exactly as before.

Omit :name to use the module's last segment without a trailing EventSource.

Summary

Functions

Declares a named stream of the event source.

Functions

stream(name, opts \\ [])

(macro)

Declares a named stream of the event source.

Options: :description and :concurrency (dimensions, see Chronicle.EventSources.ConcurrencyDimensions).