Rheo.Event (rheo v1.0.0)

Copy Markdown View Source

An immutable event stored in a Rheo stream.

Events are the durable system of record. Consumer progress (leases, ACKs, retries, dead-letters) lives in separate per-group delivery state — never as a processed flag on the event.

Persistence decoding belongs in backend codecs (e.g. Rheo.Backend.Mongo.Codec), not on this struct.

Fields

FieldTypeMeaning
idString.t()Stable unique id (use for idempotency)
streamString.t()Stream name this event belongs to
partitionnon_neg_integer()Partition within the stream
sequencepos_integer()Monotonic sequence within (stream, partition)
timestampDateTime.t()Event time (defaults to append time)
keyString.t() | nilOptional routing key (:erlang.phash2/2)
typeString.t() | nilOptional event type for queries
metadatamap()Cross-cutting headers (correlation id, producer, …)
payloadmap()Domain body (currency, curve, price, …)

Example

iex> event = %Rheo.Event{
...>   id: "evt_01",
...>   stream: "market-events",
...>   partition: 0,
...>   sequence: 1,
...>   timestamp: ~U[2026-01-15 12:00:00.000Z],
...>   key: "EUR-EURIBOR-6M",
...>   type: "curve_update",
...>   metadata: %{"correlation_id" => "abc"},
...>   payload: %{"currency" => "EUR", "price" => 2.913}
...> }
iex> {event.type, event.payload["currency"]}
{"curve_update", "EUR"}

Summary

Types

t()

An immutable stream event.

Types

t()

@type t() :: %Rheo.Event{
  id: String.t(),
  key: String.t() | nil,
  metadata: map(),
  partition: non_neg_integer(),
  payload: map(),
  sequence: pos_integer(),
  stream: String.t(),
  timestamp: DateTime.t(),
  type: String.t() | nil
}

An immutable stream event.

See the module documentation for field meanings and examples.