evoq_event_upcaster behaviour (evoq v1.14.1)
View SourceEvent upcaster behavior for schema evolution.
Upcasters transform old event versions to the current version, enabling backwards-compatible schema changes.
Usage
1. Create an upcaster module for each event type that needs transformation 2. Implement upcast/2 to transform the event 3. Register the upcaster with evoq_type_provider
Example
-module(account_created_v1_upcaster).
-behaviour(evoq_event_upcaster).
-export([upcast/2, version/0]).
version() -> 1.
upcast(#{event_type := <<"AccountCreated">>, data := Data} = Event, _Meta) ->
%% Add default email if missing (v1 -> v2)
NewData = maps:put(email, <<"unknown@example.com">>, Data),
{ok, Event#{data := NewData}}.
Summary
Functions
Apply a chain of upcasters to an event. Upcasters are applied in order. Each upcaster transforms the event for the next one in the chain.
Apply a single upcaster to an event.
Callbacks
Functions
Apply a chain of upcasters to an event. Upcasters are applied in order. Each upcaster transforms the event for the next one in the chain.
Apply a single upcaster to an event.