Electric.Shapes.EventRouter (electric v1.4.13)
View SourceRoutes replication events to shapes, returning per-shape transaction fragments.
The EventRouter wraps a Filter and adds transaction-aware routing:
- For Relation events, returns the relation for all affected shapes
- For TransactionFragment events, returns per-shape TransactionFragments with only the changes that affect each shape.
Transaction state is tracked to ensure:
- Each shape receives Begin only once per transaction (on first relevant operation)
- Each shape receives Commit only if it received operations in the transaction
- Shapes added mid-transaction are skipped for that transaction
- Shapes removed mid-transaction stop receiving events immediately
Summary
Types
Functions
@spec add_shape(t(), shape_id(), Electric.Shapes.Shape.t()) :: t()
@spec event_by_shape_handle( t(), Electric.Replication.Changes.Relation.t() | Electric.Replication.Changes.TransactionFragment.t() ) :: {%{ required(shape_id()) => Electric.Replication.Changes.Relation.t() | Electric.Replication.Changes.TransactionFragment.t() }, t()}