TigerBeetlex.CDC.Event (tigerbeetlex v0.16.50)

View Source

A struct representing TigerBeetle CDC event, see Change Data Capture.

Also check out the guide to consume CDC data using Broadway.

Summary

Functions

Creates a TigerBeetlex.CDC.Event struct from its JSON map representation.

Types

t()

@type t() :: %TigerBeetlex.CDC.Event{
  credit_account: TigerBeetlex.CDC.Account.t(),
  debit_account: TigerBeetlex.CDC.Account.t(),
  ledger: non_neg_integer(),
  timestamp: non_neg_integer(),
  transfer: TigerBeetlex.CDC.Transfer.t(),
  type: TigerBeetlex.Types.event_type()
}

Functions

cast!(params)

@spec cast!(%{required(binary()) => term()}) :: t() | no_return()

Creates a TigerBeetlex.CDC.Event struct from its JSON map representation.

This converts all keys to atom, parses all integers, converts all binary IDs and creates flags structs from their integer representation.

Since the format is expected to be well defined, the function raises if it can't cast.

Note that the TigerBeetle CDC message payload is a string, you have to decode it to a map (using, e.g. Jason) before you pass it to this function.

Examples

alias TigerBeetlex.CDC.Event

message_body
|> Jason.decode!()
|> Event.cast!()

#=> %TigerBeetlex.CDC.Event{type: :single_phase, transfer: %TigerBeetlex.CDC.Transfer{}, ...}