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:
dataholds the decoded payload when a:decodefunction is configured, or the raw binary when it is not. An event recorded without a payload comes back asnilrather than"".metadatais a plain map instead of a list ofUmaDb.V1.MetadataEntrystructs.uuidisnilwhen the event carries no identifier, rather than"".tracking_infois the cursor recorded alongside the append, as a%{source: String.t(), position: non_neg_integer()}map, ornilwhen the event was appended without one.
UmaDbClient.read/2 and UmaDbClient.subscribe/2 are unaffected — they
continue to return UmaDb.V1.SequencedEvent structs.
Summary
Functions
Converts an UmaDb.V1.SequencedEvent into an UmaDbClient.Event.
Types
@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 }
@type tracking_info() :: %{source: String.t(), position: non_neg_integer()}
Functions
@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.