Releases: primait/event_sourcing.rs
0.10.1
0.10.0
[[#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
Commits
0.9.0
Added
- Added tracing spans for application of policies and projection of events
[0.8.0]
Added
- [[#129]]: Atomic read/writes for aggregate states.
AggregateManager
:lock
method acquires a lock for the given aggregate state, preventing other atomic accesses.
Dropping the lock releases the resource.
EventStore
:lock
trait function, required to return aEventStoreLockGuard
.
EventStoreLockGuard
, wrapping anUnlockOnDrop
trait object.UnlockOnDrop
marker trait, required for concrete types to be used asEventStoreLockGuard
.PgStore
:lock
implementation using Postgres' advisory locks.
PgStoreLockGuard
, holding the actual Postgres' lock and releasing it on drop.
[0.7.1]
Added
- [[#114]]: Default
EventStore
implementation for everyBox<dyn EventStore<Manager = _>>
. This allows to define
in theAggregateManager
theEventStore
associated type asBox<dyn EventStore<Manager = _>>
(withSend
+
Sync
bounds). - [[#115]]: Added
apply_events
toAggregate
with default implementation. - [[#122]]:
Consistency
level enum.consistency
function toProjector
to instruct theEventStore
on the persistence guarantees with default
implementation returningConsistency::Strong
.
- [[#123]]: Added
postgres
documentation in docs.rs withpackage.metadata.docs.rs
inCargo.toml
. Improved
modules documentation.
Changed
- [[#117]]:
AggregateState::new
second parameter fromUuid
toimpl Into<Uuid>
.AggregateManager::load
first parameter fromUuid
toimpl Into<Uuid>
.AggregateState::delete
first parameter fromUuid
toimpl Into<Uuid>
.
- [[#118]]: Merged rebuild examples into one; removed mains and migrations from examples.
[0.7.0]
Note: this version contains hard breaking changes and may take a lot of time in order to upgrade library version!
Refer to: [#107], [#108] and [#109]
Added
-
AggregateManager
- should implement
name
function that act asIdentifier
. Be sure to not change the name previously set in
Identifier::name
function. This would cause the store to create a new table, losing pre-migration events. - depends on
Aggregate
, so user must implementAggregate
trait in order to implementAggregateManager
trait. - should implement
EventStore
associated type.
- should implement
-
EventStore::delete
function with which an entire aggregate could be deleted byaggregate_id
. -
PgStore
setup
function to create table and indexes if not exists. This function should be used only once at your
application startup. It tries to create the event table and its indexes if they not exist.set_projectors
function to set the store projectors list.set_policies
function to set the store policies list.PgStore
and all its dependencies are now cloneable. Is behind and Arc and is safely cloneable.
-
Projector
should implementdelete
function.
Changed
-
Aliases of exposed traits and struct are hardly changed. Now most of internal objects are flatten in
esrs
module. -
Aggregate
- is now pure. API changed so user have to implement
Aggregate
for logic andAggregateManager
in
order to handle persistence layer. handle_command
state argument changed from&AggregateState<Self::State>
to&Self::State
.apply_event
payload
parameter changed from reference to value (Self::Event
).
- is now pure. API changed so user have to implement
-
AggregateManager
- is now dependent by
Aggregate
and no default implementation is provided. To complete the migration for an
aggregate handling the persistence layer is now mandatory for your type to implementAggregateManager
. - renamed function
handle
inhandle_command
. event_store
changed to return a reference to it's associated typeEventStore
.
- is now dependent by
-
EventStore
Event
andError
generics removed in favour ofManager: AggregateManager
associated type.
-
PgStore
new
function is now sync and its return value is no longer aResult
butSelf
. RemovedAggregate
type param.new
takes ownership of pool; removed projectors and policies params. Useset_projectors
orset_policies
instead to add them to the store.rebuild_events
renamed intostream_events
. Now it takes ansqlx::Executor
parameter.- policies behaviour is now that if one of them fails they fail silently. (override this behaviour with
Aggregate::store_events
usingEventStore::persist
function). Event
andError
trait generic params removed in favour ofManager: AggregateManager
.projectors
andpolicies
returns anArc
to value.
-
PgProjector
- renamed to
Projector
. - second param changed from
&mut PoolConnection<Postgres>
to&mut PgConnection
. Event
andError
trait generic params removed in favour ofManager: AggregateManager
.
- renamed to
-
PgPolicy
- renamed to
Policy
. Event
andError
trait generic params removed in favour ofManager: AggregateManager
.- moved to
esrs
root module. - removed second param (
&Pool<Postgres>
).
- renamed to
-
Policy::handle_event
does not havePool<Postgres
anymore as param. Executor should be put in the policy at
instantiation time.
Removed
-
sqlite
feature and its implementation. -
Aggregate
validate_command
is removed; now validation should be made inhandle_command
.event_store
function is moved fromAggregate
toAggregateManager
.
-
EventStore
run_policies
. To customize the way policies behave overrideAggregate::store_events
using
EventStore::persist
function.close
function.
-
PgStore
test
function. Use#[sqlx::test]
in your tests to test the store.begin
,commit
androllback
functions.Event
generic type.Error
generic type.Projector
generic type.Policy
generic type.
-
Identifier
trait. -
Eraser
trait. -
PgProjectorEraser
trait. -
EraserStore
trait. -
ProjectorStore
trait. -
StoreEvent
bounds ofEvent
generic. -
AggregateState
new_with_state
removed due to potential inconsistency while loading state.
[0.6.2]
Changed
- Bump min version of supported Rust to 1.58 since <1.58 fails to resolve sqlx-core dep
Commits
- Bump to 0.9.0 for release (#132) by Oliver Browne
- [PLATFORM-743]: Investigate adding tracing to ESRS (#130) by Oliver Browne
0.8.0
0.7.1
- v0.7.1 (#124) by Simone Cottini
- Consistency level in projector and store (#122) by Simone Cottini
- Flag to publish postgres stuff in docs.rs + some modules doc (#123) by Simone Cottini
- Add apply_events to Aggregate (#115) by Simone Cottini
- Removed some useless mains; removed useless migrations; created single repo for rebuilders (#118) by Simone Cottini
- Add default implementation of EventStore for every Box (#114) by Simone Cottini
- Modify first new param from Uuid to impl Into (#117) by Simone Cottini
0.7.0
- v0.7.0 (#110) by Simone Cottini
- Some docs; changelog and remove dead code (#109) by Simone Cottini
- Rename get_all in stram_events; update rebuilder example (#108) by Simone Cottini
- [PLATFORM-606]: [esrs] Try to make persistence flow configurable (#107) by Simone Cottini
- [PLATFORM-573]: [esrs] POC different projectors on same table (#106) by Oliver Browne
- [PLATFORM-627]: [Esrs] Change apply_event function (#105) by Simone Cottini
- [PLATFORM-619]: [Esrs] Remove identifier trait and move name in aggregate (#104) by Simone Cottini
- [PLATFORM-618]: [Esrs] Restore transaction instead of using connection (#103) by Simone Cottini
- [PLATFORM-617]: [Esrs] Remove sqlite implementation (#102) by Simone Cottini
- [PLATFORM-572]: [Esrs] Remove
event_store
from Aggregate (#98) by Simone Cottini - [PLATFORM-573]: [esrs] POC different projectors on same table (#100) by Oliver Browne
- [PLATFORM-573]: [esrs] POC different projectors on same table (#99) by Oliver Browne
- Fix typos and unnecessary path prefix (#94) by Simone Cottini
0.6.2
- Fix deploy script
- 0.6.2 (#93)
- [PLATFORM-514]: [Esrs] Update sqlx & uuid (#91)
- Merge pull request #86 from primait/docs_typo
- fix doc typos
- Add catalog-info.yaml for Backstage (#85)
- Merge pull request #84 from primait/split-up-policies-from-persist
- expose next sequence number from aggregate state
- remove defunct handle_command impl
- enable decoupling of persist & policies