User-facing change event struct.
Each replicated row change is cast into a %WalEx.Event{} containing the
table (name), kind (type: :insert | :update | :delete), record(s),
changed fields (for updates), commit timestamp, LSN, and source metadata.
Host modules use WalEx.Event, name: MyApp to gain the on_insert/4,
on_update/4, on_delete/4, and on_event/2 macros from WalEx.Event.Dsl.
Summary
Functions
Installs the WalEx.Event.Dsl macros (on_insert/4, on_update/4,
on_delete/4, on_event/2) and filter_events/1,4 helpers into the
calling module, bound to the given :name (WalEx app instance).
Casts a WalEx.Changes.{NewRecord,UpdatedRecord,DeletedRecord} into an
Event struct, attaching source metadata for app_name. Returns nil for
unrecognised inputs.
Casts every change in a list (typically txn.changes) to an Event for app_name.
Filter out events by table and type (optional) from transaction and cast to Event struct
Types
@type t() :: %WalEx.Event{ changes: map() | nil, lsn: {integer(), integer()}, name: atom(), new_record: map() | nil, old_record: map() | nil, source: WalEx.Event.Source.t(), timestamp: DateTime.t(), type: :insert | :update | :delete }
Functions
Installs the WalEx.Event.Dsl macros (on_insert/4, on_update/4,
on_delete/4, on_event/2) and filter_events/1,4 helpers into the
calling module, bound to the given :name (WalEx app instance).
Casts a WalEx.Changes.{NewRecord,UpdatedRecord,DeletedRecord} into an
Event struct, attaching source metadata for app_name. Returns nil for
unrecognised inputs.
Casts every change in a list (typically txn.changes) to an Event for app_name.
Filter out events by table and type (optional) from transaction and cast to Event struct