Releases: yousty/event_store_client
v3.2.0
Add ability to override the way how event class is resolved from event type.
Previously the event was resolved from an event type only in the pre-defined way - Object.const_get(event_type)
. Current release adds an ability to add your own resolver using config.event_class_resolver
config option. You should define a Proc
that accepts a string and returns a class. Example:
EventStoreClient.configure do |config|
config.event_class_resolver = proc { |event_type| event_type == 'some-event' ? SomeEvent : AnotherEvent }
end
If config.event_class_resolver
returns nil
- config.default_event_class
class will be picked.
v3.1.0
v3.0.0
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 allEventStoreClient.client
methods were returning eitherDry::Monads::Success
orDry::Monads::Failure
, and now they return the result which corresponds to the called method. In cases whereDry::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.
v2.3.0
v2.3.0-beta2
Make EventStoreClient::GRPC::Client#config
public
v2.3.0-beta
- Add a possibility to provide define configurations.
Example:
EventStoreClient.configure do |config|
config.eventstore_url = 'esdb://admin:changeit@localhost:2111,localhost:2112,localhost:2113'
end
EventStoreClient.configure(name: :another_config) do |config|
config.eventstore_url = 'esdb://admin:changeit@localhost:2115/?tls=false'
end
Now you can use it like so:
EventStoreClient.client.read(...) # default(unnamed) config will be used
EventStoreClient.client(config_name: :another_config).read(...) # :another_config config will be used
Breaking changes:
- To configure a mapper, you have to provide
:config
keyword argument. If you use default mapper - you don't have to change anything.
Example:
EventStoreClient.configure do |config|
config.mapper = EventStoreClient::Mapper::Encrypted.new(some_key_repository, config: config)
end
v2.2.0
- Add ability to configure channel arguments
Now you can configure channel arguments. Example:
EventStoreClient.configure do |config|
config.channel_args = { 'grpc.min_reconnect_backoff_ms' => 200 }
end
More info can be found in configuration docs
v2.1.5
- All generated code, based of Protos should be scoped to the client's namespace
- Temporary disable bin/rebuild_protos script