Merry Christmas to all, > On Dec 25, 2017, at 1:27 AM, Niclas Hedhman <nic...@hedhman.org> wrote: > > Merry Christmas everyone, > > > Invariant checking is about ensuring that an Entity Aggregate is never > accessible in a incoherent state. Transactions/UnitOfWork takes care of the > atomicity, but there is no built-in mechanism to ensure that an invalid > state has not occurred "naturally", say, the total allocated container CPU > load isn't higher than the host's available CPU capacity. At the moment, > such thing needs to be built in somewhere, and without front-facing > services handling such entities, it is quite easy for developers to > "forget" or "didn't know" such rules. >
for Entity invariant checks I found useful hook via UnitOfWorkCallback. The one that is executed per entity instance if entity implements UnitOfWorkCallback. Basically this is how I do cross fields validation for entities. I am thinking if this hook could be optimized and executed only if entity changed, now it is executed for all loaded instances. cheers, Tibor