0.10.0
angelo-rendina-prima
released this
01 Dec 10:34
·
56 commits
to master
since this release
[[#133]]: atomic read/writes rework to avoid deadlocks in Policies.
Changed
Aggregate
:apply_events
has been removed, and its default implementation moved to a method ofAggregateState
.
AggregateManager
:lock_and_load
acquires a lock, then loads into memory the AggregateState
preventing other atomic accesses. Dropping the AggregateState releases the resource.lock
has been removed in favour oflock_and_load
.handle_command
does not return the AggregateState anymore. This avoids race conditions where the
returned state is already outdated, if another concurrent access has taken place at the same time.apply_events
has been removed, and its default implementation moved to a method ofAggregateState
.load
has been changed to return aResult<Option<_>, _>
, to explicit expose errors.
AggregateState
:- new
lock
field, which contains the exclusive access guard created whenlock_and_load
ing.
All other fields are now private for better encapsulation. new
takes no argument, and generates a new state with a random UUID.with_id
generates a new state with the given UUID.apply_store_events
applies the given list of Events on self.set_lock
andtake_lock
methods to set and get the lock,
to use when overriding the AggregateManager functionality.
- new