Attribute Macro eventually_macros::aggregate_root
source · #[aggregate_root]
Expand description
Implements a newtype to use the eventually::aggregate::Root
instance with
user-defined eventually::aggregate::Aggregate
types.
§Context
The eventually API uses aggregate::Root
to manage the versioning and list of events to commit for an Aggregate
instance.
Domain commands are to be implemented on the aggregate::Root<T>
instance, as it gives
access to use Root<T>.record_that
or Root<T>.record_new
to record Domain Events.
However, it’s not possible to use impl aggregate::Root<MyAggregateType>
(MyAggregateType
being an example of user-defined Aggregate
type) outside the eventually
crate (E0116).
Therefore, a newtype that uses aggregate::Root<T>
is required.
This attribute macro makes the implementation of a newtype easy, as it Implements
conversion traits from and to aggregate::Root<T>
and implements automatic deref
through std::ops::Deref
and std::ops::DerefMut
.
§Panics
This method will panic if the Aggregate Root type is not provided as a macro parameter.