Skip to content

Split persisted and domain events #168

@alexeyzimarev

Description

@alexeyzimarev

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

EVE-42

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlinearSync the issue to Linear

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions