KubeMQ
Client SDKsElixirReference

Events Store

Persistent event structs and replay options — KubeMQ Elixir SDK reference.

Events Store provides persistent messaging where events are stored on the server and can be replayed. Subscribers specify a starting position to control which events they receive.

Structs

KubeMQ.EventStore

Used to publish persistent events.

FieldTypeDescription
idString.t()Auto-generated message ID
channelString.t()Target channel name
metadataString.t()Optional metadata string
bodyString.t() | binary()Message payload
client_idString.t()Sender client ID (auto-populated)
tagsmap()Optional key-value tags

KubeMQ.EventStoreReceive

Received by subscribers during replay or live delivery.

FieldTypeDescription
idString.t()Message ID
channelString.t()Source channel
metadataString.t()Metadata string
bodyString.t() | binary()Message payload
timestampinteger()Server timestamp
sequenceinteger()Sequence number
tagsmap()Key-value tags

KubeMQ.EventStoreResult

Confirmation returned after storing an event.

FieldTypeDescription
idString.t()Message ID
sentboolean()Whether the event was stored
errorString.t()Error message if failed

Start Positions

PositionValueDescription
New only:start_new_onlyOnly events published after subscribing
From first:start_from_firstReplay all stored events from the beginning
From last:start_from_lastStart from the most recent stored event
At sequence{:start_at_sequence, n}Start from a specific sequence number
At time{:start_at_time, unix_seconds}Start from a specific Unix timestamp
Time delta{:start_at_time_delta, ms}Start from N milliseconds ago

Publishing

event = KubeMQ.EventStore.new(
  channel: "audit-log",
  body: "user.login",
  metadata: "audit"
)

{:ok, result} = KubeMQ.Client.send_event_store(client, event)
IO.puts("Stored: #{result.sent}")

Subscribing with Replay

{:ok, sub} = KubeMQ.Client.subscribe_to_events_store(client, "audit-log",
  start_at: :start_from_first,
  group: "processors",
  on_event: fn event ->
    IO.puts("Seq #{event.sequence}: #{event.body}")
  end
)

KubeMQ.Subscription.cancel(sub)

See Also

Was this page helpful?

On this page