Macro for defining a mapping shared across every read model variant of a given identity, without repeating it on each variant module.
A global handler is never registered as a projection on its own. Its from/2 mappings are
merged into every read model or declarative projection whose variant_of/2 names the same
identity, before that variant's own non-entering events are reclassified into update-only
joins - so a shared mapping for a non-entering event is turned into an update-only join
exactly like a mapping declared directly on the variant.
Quick Example
defmodule MyApp.Projections.WorkItemTitleHandler do
use Chronicle.Projections.GlobalHandler, identity: MyApp.ReadModels.WorkItem
from MyApp.Events.TitleChanged,
set: [title: :title]
endA mapping that targets a member some variant lacks is a declaration error
(Chronicle.Projections.GlobalHandlerPropertyNotOnVariant), raised at registration time -
not a silently skipped mapping.
Registering with Chronicle.Client
{Chronicle.Client,
...
global_handlers: [MyApp.Projections.WorkItemTitleHandler]}Or use otp_app: auto-discovery - modules that export __chronicle_global_handler__/1 are
discovered automatically.
Summary
Functions
Declares how an event maps onto every variant of this handler's identity.
Functions
Declares how an event maps onto every variant of this handler's identity.
See Chronicle.ReadModels.ReadModel for full options documentation.