UmaDbClient.Event (uma_db_client v0.7.5)

Copy Markdown

A recorded event in a plain Elixir shape.

This is what the facade generated by use UmaDbClient returns from read/2 and subscribe/2, in place of the generated UmaDb.V1.SequencedEvent struct:

  • data holds the decoded payload when a :decode function is configured, or the raw binary when it is not. An event recorded without a payload comes back as nil rather than "".
  • metadata is a plain map instead of a list of UmaDb.V1.MetadataEntry structs.
  • uuid is nil when the event carries no identifier, rather than "".
  • tracking_info is the cursor recorded alongside the append, as a %{source: String.t(), position: non_neg_integer()} map, or nil when the event was appended without one.

UmaDbClient.read/2 and UmaDbClient.subscribe/2 are unaffected — they continue to return UmaDb.V1.SequencedEvent structs.

Summary

Types

t()

@type t() :: %UmaDbClient.Event{
  data: term(),
  metadata: %{required(String.t()) => String.t()},
  position: non_neg_integer() | nil,
  tags: [String.t()],
  tracking_info: tracking_info() | nil,
  type: String.t(),
  uuid: String.t() | nil
}

tracking_info()

@type tracking_info() :: %{source: String.t(), position: non_neg_integer()}

Functions

from_sequenced(sequenced, decode)

@spec from_sequenced(UmaDb.V1.SequencedEvent.t(), term()) :: t()

Converts an UmaDb.V1.SequencedEvent into an UmaDbClient.Event.

decode is a one-argument function, a {module, function} tuple, a module exporting decode!/1, or nil to leave data as raw bytes.

An empty payload is never passed to decode — it becomes nil. Decoders such as Jason.decode!/1 raise on an empty string, so this keeps events recorded without a payload readable.