Chronicle.Events.AppendedEvent (cratis_chronicle v3.16.1)

Copy Markdown View Source

An event read back from an event sequence, decoded into the event struct it was appended as.

Returned by Chronicle.EventSequences.EventLog.get_for_event_source/2 and get_from_sequence_number/2 when called with decode: true.

  • :event — the event struct for a registered event type, or nil when the event type is not registered with this client (or the event was redacted); the decoded payload is then still available in :raw.
  • :raw — the event content as a map with the wire (camelCase) keys.
  • :context — the Chronicle.Events.EventContext.
  • :type — %{id: String.t(), generation: non_neg_integer()}.
  • :redacted? / :redaction — set for events that were redacted for compliance; the redaction carries the :reason and the :original_event_type id.

Summary

Functions

Decodes a wire AppendedEvent, resolving the event struct from event_types (a list of event type modules).

Types

t()

@type t() :: %Chronicle.Events.AppendedEvent{
  context: Chronicle.Events.EventContext.t(),
  event: struct() | nil,
  raw: map(),
  redacted?: boolean(),
  redaction: %{reason: String.t(), original_event_type: String.t()} | nil,
  type: %{id: String.t(), generation: non_neg_integer()} | nil
}

Functions

from_wire(appended, event_types)

@spec from_wire(map(), [module()]) :: t()

Decodes a wire AppendedEvent, resolving the event struct from event_types (a list of event type modules).