Skip to content

v0.19.0

Compare
Choose a tag to compare
@paneq paneq released this 06 Nov 11:10
· 6752 commits to master since this release
b8f5122

RailsEventStore

  • Add: publish_events(events) API which allows publishing a collection of events. Handlers are executed in the order the events were provided. First all handlers to the 1st event, then all handlers to the 2nd event and so on...

    publish_events([e0, e1]) is equivalent to publish_event([e0]); publish_event([e1]) but the events are stored transactionally (when using RailsEventStoreActiveRecord).

RubyEventStore

  • Add: publish_events(events) API which allows publishing a collection of events.
  • Fix: Fix one-shot (dynamic) subscribers behavior when exception occurs during processing a block. A dynamic subscriber was not unsubscribed when an exception happened. Not it will be unsubscribed.
  • Fix: RubyEventStore::Event#hash method was implemented. Now identical events (in terms of class, event_id and data) can be safely used as keys in Hash or members of a Set. Notice: metadata is ignored when comparing events.
  • Change: RubyEventStore::InMemoryRepository uses append_to_stream(events, stream_name, expected_version) API instead of create(event, stream_name)
  • Change: RubyEventStore::InMemoryRepository can detect concurrent writes to the same stream

RailsEventStoreActiveRecord

  • Breaking: Uses two tables instead of one to save events and events in streams separately. Use following commands to migrate schema and data:

    rails generate rails_event_store_active_record:v1_v2_migration
    rake db:migrate
    

    This migration is intended to be run in offline mode. You need to edit this migration file and fill out the def preserve_positions?(stream_name) method based on the instructions you will find there.

    If by any chance you cannot migrate the schema right now you can (for some limited) time switch to old repository, available as RailsEventStoreActiveRecord::LegacyEventRepository:

    Rails.application.configure do
      config.to_prepare do
        Rails.configuration.event_store = RailsEventStore::Client.new(
          repository: RailsEventStoreActiveRecord::LegacyEventRepository.new
        )
      end
    end

    Mind that we're going to eventually remove RailsEventStoreActiveRecord::LegacyEventRepository in one of next major releases.

  • Breaking: Passing UUID is no longer accepted as expected_version of previous event in a stream. Use integers as sequence numbers for that purpose.

  • Breaking: delete_stream no longer removes an events. The new behaviour is as follows:

    • EventRepository#delete_stream will unlink events from given stream, leave it in others
    • LegacyEventRepository#delete_stream will move events from given stream to global stream named all
  • Change: 3 ways of providing expected_version. Read more at our expected_version option explained article in the documentation

  • Change: Properly detects race conditions in case of concurrent writes to the same stream using optimistic locking strategy when a proper expected_version is used. Read more at our expected_version option explained article in the documentation

  • Change: append_to_stream(events, stream_name, expected_version) API instead of create(event, stream_name) which allows storing a collection of events transactionally and optimistic locking

  • Add: LegacyEventRepository to support old database schema and allow to prepare for migration to new schema used by EventRepository.

  • Breaking: RailsEventStoreActiveRecord::EventRepository cannot be initialized with an adapter.

  • Add: RailsEventStoreActiveRecord::EventRepository can append the same event to multiple streams without the need to duplicate the event with a different UUID.

AggregateRoot

  • Change: Properly provides lower layer with expected_version to detect concurrent writes to the same stream. Can raise RubyEventStore::EventDuplicatedInStream (aliased as RailsEventStore::EventDuplicatedInStream) when there is a concurrency conflict.
  • Change: unpublished_events is publicly available, read-only iterator.

RailsEventStore::RSpec

  • no changes

BoundedContext

  • no changes