eventuous
eventuous copied to clipboard
Split persisted and domain events
For a while, I advocated treating events as contracts and keeping them clean of sophisticated types like value objects.
It solves the issue of serialisation as it should work unconditionally, but it introduces some issues:
- Repeated wrapping and unwrapping of value objects in the aggregate and the state code
- Applying mapping attributes (which are infrastructure-oriented) to domain events
- Lack of persistence control from the domain model side (I might not want to persist all the events)
Similar to #82, it is possible to map persisted events to domain events (and back) to separate those concerns.
Here's the idea:
- Add an optional two-way mapping
- Treat it as an addition, meaning look inside the map first and pass through unmapped types