serverlesstechnology / cqrs

A lightweight, opinionated CQRS and event sourcing framework.
Other
346 stars 36 forks source link

Question: Default trait for aggregate #50

Closed epsilonhalbe closed 1 year ago

epsilonhalbe commented 1 year ago

Why is it necessary to have the Default trait for aggregates? Is this to avoid a "Aggregate not found error"?

I have used CQRS in haskell, and reading this rust implementation is really neat and tidy, good work!

davegarred commented 1 year ago

@epsilonhalbe any time an aggregate is loaded in an event sourced system, a new Aggregate is created (via the Default trait) and all previous events are applied to that aggregate. This means it will be used once every time a command is fired.

In the event you use aggregate sourcing, the Default trait will only be used when the first command is fired, the aggregate state will be persisted after that.

Thanks for the interest!

epsilonhalbe commented 1 year ago

Thanks!