Class: EventStoreClient::GRPC::Commands::Streams::Append
- Defined in:
- lib/event_store_client/adapters/grpc/commands/streams/append.rb
Constant Summary collapse
- ALLOWED_EVENT_METADATA =
%w[type content-type created_at].freeze
Instance Method Summary collapse
Methods inherited from Command
Methods included from Configuration
Instance Method Details
#call(stream, events, options: {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/event_store_client/adapters/grpc/commands/streams/append.rb', line 20 def call(stream, events, options: {}) return unless events.any? serialized_events = events.map { |event| config.mapper.serialize(event) } expected_version = [:expected_version] res = nil serialized_events.each_with_index do |event, i| expected_version += i if expected_version res = append(stream, event, expected_version) break if res.failure? end res.success? ? Success(events) : Failure(res.failure) end |