View Source Commanded.EventStore.RecordedEvent (Commanded v1.4.6)

Contains the persisted stream identity, type, data, and metadata for a single event.

Events are immutable once recorded.

Recorded event fields

  • event_id - a globally unique UUID to identify the event.

  • event_number - a globally unique, monotonically incrementing and gapless integer used to order the event amongst all events.

  • stream_id - the stream identity for the event.

  • stream_version - the version of the stream for the event.

  • causation_id - an optional UUID identifier used to identify which message you are responding to.

  • correlation_id - an optional UUID identifier used to correlate related messages.

  • data - the event data deserialized into a struct.

  • metadata - a string keyed map of metadata associated with the event.

  • created_at - the datetime, in UTC, indicating when the event was created.

Summary

Functions

Enrich the event's metadata with fields from the RecordedEvent struct and any additional metadata passed as an option.

Types

@type causation_id() :: uuid() | nil
@type correlation_id() :: uuid() | nil
@type created_at() :: DateTime.t()
@type data() :: domain_event()
@type domain_event() :: struct()
@type enriched_metadata() :: %{
  :event_id => event_id(),
  :event_number => event_number(),
  :stream_id => stream_id(),
  :stream_version => stream_version(),
  :correlation_id => correlation_id(),
  :causation_id => causation_id(),
  :created_at => created_at(),
  optional(atom()) => term(),
  optional(String.t()) => term()
}
@type event_id() :: uuid()
@type event_number() :: non_neg_integer()
@type event_type() :: String.t()
@type metadata() :: map()
@type stream_id() :: String.t()
@type stream_version() :: non_neg_integer()
@type t() :: %Commanded.EventStore.RecordedEvent{
  causation_id: causation_id(),
  correlation_id: correlation_id(),
  created_at: created_at(),
  data: data(),
  event_id: event_id(),
  event_number: event_number(),
  event_type: event_type(),
  metadata: metadata(),
  stream_id: stream_id(),
  stream_version: stream_version()
}
@type uuid() :: String.t()

Functions

Link to this function

enrich_metadata(event, opts)

View Source
@spec enrich_metadata(t(), [{:additional_metadata, map()}]) :: enriched_metadata()

Enrich the event's metadata with fields from the RecordedEvent struct and any additional metadata passed as an option.