Skip to content

Releases: primait/event_sourcing.rs

0.10.1

06 Feb 16:07
2028488
Compare
Choose a tag to compare

Fixed

[[#136]]: select_all query ordering was missing of sequence_number.


Commits

  • Update changelog (#137) by Simone Cottini
  • Order by occurred_on and sequence number in select_all statement (#136) by Simone Cottini

0.10.0

01 Dec 10:34
241903c
Compare
Choose a tag to compare

[[#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 of AggregateState.
  • 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 of lock_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 of AggregateState.
    • load has been changed to return a Result<Option<_>, _>, to explicit expose errors.
  • AggregateState:
    • new lock field, which contains the exclusive access guard created when lock_and_loading.
      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 and take_lock methods to set and get the lock,
      to use when overriding the AggregateManager functionality.

Commits

  • v0.10.0 (#134) by angelo-rendina-prima
  • lock inside state (#133) by angelo-rendina-prima

0.9.0

21 Nov 10:51
6c79c7d
Compare
Choose a tag to compare

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 a EventStoreLockGuard.
    • EventStoreLockGuard, wrapping an UnlockOnDrop trait object.
    • UnlockOnDrop marker trait, required for concrete types to be used as EventStoreLockGuard.
    • 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 every Box<dyn EventStore<Manager = _>>. This allows to define
    in the AggregateManager the EventStore associated type as Box<dyn EventStore<Manager = _>> (with Send +
    Sync bounds).
  • [[#115]]: Added apply_events to Aggregate with default implementation.
  • [[#122]]:
    • Consistency level enum.
    • consistency function to Projector to instruct the EventStore on the persistence guarantees with default
      implementation returning Consistency::Strong.
  • [[#123]]: Added postgres documentation in docs.rs with package.metadata.docs.rs in Cargo.toml. Improved
    modules documentation.

Changed

  • [[#117]]:
    • AggregateState::new second parameter from Uuid to impl Into<Uuid>.
    • AggregateManager::load first parameter from Uuid to impl Into<Uuid>.
    • AggregateState::delete first parameter from Uuid to impl 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 as Identifier. 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 implement Aggregate trait in order to implement AggregateManager trait.
    • should implement EventStore associated type.
  • EventStore::delete function with which an entire aggregate could be deleted by aggregate_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 implement delete 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 and AggregateManager 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).
  • 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 implement AggregateManager.
    • renamed function handle in handle_command.
    • event_store changed to return a reference to it's associated type EventStore.
  • EventStore

    • Event and Error generics removed in favour of Manager: AggregateManager associated type.
  • PgStore

    • new function is now sync and its return value is no longer a Result but Self. Removed Aggregate type param.
    • new takes ownership of pool; removed projectors and policies params. Use set_projectors or set_policies
      instead to add them to the store.
    • rebuild_events renamed into stream_events. Now it takes an sqlx::Executor parameter.
    • policies behaviour is now that if one of them fails they fail silently. (override this behaviour with
      Aggregate::store_events using EventStore::persist function).
    • Event and Error trait generic params removed in favour of Manager: AggregateManager.
    • projectors and policies returns an Arc to value.
  • PgProjector

    • renamed to Projector.
    • second param changed from &mut PoolConnection<Postgres> to &mut PgConnection.
    • Event and Error trait generic params removed in favour of Manager: AggregateManager.
  • PgPolicy

    • renamed to Policy.
    • Event and Error trait generic params removed in favour of Manager: AggregateManager.
    • moved to esrs root module.
    • removed second param (&Pool<Postgres>).
  • Policy::handle_event does not have Pool<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 in handle_command.
    • event_store function is moved from Aggregate to AggregateManager.
  • EventStore

    • run_policies. To customize the way policies behave override Aggregate::store_events using
      EventStore::persist function.
    • close function.
  • PgStore

    • test function. Use #[sqlx::test] in your tests to test the store.
    • begin, commit and rollback 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 of Event 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

17 Nov 14:53
fd7510c
Compare
Choose a tag to compare
  • v0.8.0 (#131) by angelo-rendina-prima
  • Pessimistic lock (#129) by angelo-rendina-prima
  • Prefer Deref default impl rather than box (#126) by Simone Cottini
  • Make StoreEvent debuggable (#120) by Gian Lu

0.7.1

10 Oct 12:26
57d1dd2
Compare
Choose a tag to compare
  • 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

29 Sep 14:20
d7a25bb
Compare
Choose a tag to compare
  • 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

20 Jun 09:08
e36f126
Compare
Choose a tag to compare
  • 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

0.6.1

11 Jan 08:26
e40ce2b
Compare
Choose a tag to compare
  • Remove public schema namespace from index creation (#83)

0.6.0

22 Dec 11:48
8758384
Compare
Choose a tag to compare
  • [PG-172]: transactionally emit/persist multiple events from handling command (#78)
  • add examples crates to workspace (#77)
  • [PG-172]: add 'simpler' aggregate trait (#75)

0.5.5

15 Dec 13:19
10df944
Compare
Choose a tag to compare
  • Handle begin transaction error (#72)