Skip to content

v3.0.0

Compare
Choose a tag to compare
@intale intale released this 06 Jan 10:09
· 18 commits to master since this release
  • EventStoreClient::DeserializedEvent now accepts :custom_metadata key. You can pass any value there. Example:
EventStoreClient::DeserializedEvent.new(custom_metadata: { foo: :bar, baz: :oof })

That hash will be directly passed to the EventStore DB in the custom_metadata attribute.

  • Added EventStoreClient::DeserializedEvent#system? method which detects whether an event is a system event. System events have #type which starts from $ sign.

  • Adjusted EventStoreClient::DeserializedEvent#== not to take into account #commit_position and #prepare_position. The reason behind this change is because those values may be different when reading from $all stream and when reading from the specific stream

Breaking changes:

  • EventStoreClient::DeserializedEvent#metadata is now split on #metadata and #custom_metadata. All keys, that were present in #metadata before(upon event deserialization when reading from stream), such as "created_at", "encryption", etc, are now located under #custom_metadata. It means if you were relying on #metadata before to retrieve that info - you should adopt your code to rely on #custom_metadata now. Example:

Before:

event = EventStoreClient::DeserializedEvent.new
EventStoreClient.client.append_to_stream('some-stream', event)
event_from_db = EventStoreClient.client.read('some-stream').last
event_from_db.metadata['created_at'] # => returns string representation of time, e.g. `"2022-12-27 11:40:54 UTC"`

After:

event = EventStoreClient::DeserializedEvent.new
EventStoreClient.client.append_to_stream('some-stream', event)
event_from_db = EventStoreClient.client.read('some-stream').last
event_from_db.metadata # Now contains only "type", "content-type" and "created" keys
event_from_db.custom_metadata['created_at'] # => returns string representation of time, e.g. `"2022-12-27 11:40:54 UTC"`
  • Drop dry-monads gem dependency. Previously all EventStoreClient.client methods were returning either Dry::Monads::Success or Dry::Monads::Failure, and now they return the result which corresponds to the called method. In cases where Dry::Monads::Failure object was returned - it raises the appropriate error now. Example:

Before:

EventStoreClient.client.read('$all') 
# => Dry::Monads::Success([<#EventStoreClient::DeserializedEvent>])
EventStoreClient.client.read('non-existing-stream')
# => Dry::Monads::Failure(:stream_not_found)
EventStoreClient.client.subscribe_to_all(handler: proc { |result| event = result.success; p event })

After:

EventStoreClient.client.read('$all') 
# => [<#EventStoreClient::DeserializedEvent>]
EventStoreClient.client.read('non-existing-stream')
# => raises EventStoreClient::StreamNotFoundError error
EventStoreClient.client.subscribe_to_all(handler: proc { |event| p event })

Please check updated guides in docs/ for more information.