Class: EventStoreClient::GRPC::Commands::Streams::LinkToMultiple

Inherits:
Command
  • Object
show all
Defined in:
lib/event_store_client/adapters/grpc/commands/streams/link_to_multiple.rb

Instance Method Summary collapse

Methods inherited from Command

#connection_options, #initialize, #metadata, #request, #service, use_request, use_service

Methods included from Configuration

#config

Constructor Details

This class inherits a constructor from EventStoreClient::GRPC::Commands::Command

Instance Method Details

#call(stream_name, events, options:, &blk) ⇒ 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.

See Also:

  • EventStoreClient::GRPC::Commands::Streams::LinkToMultiple.{EventStoreClient{EventStoreClient::GRPC{EventStoreClient::GRPC::Client{EventStoreClient::GRPC::Client#link_to}


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/event_store_client/adapters/grpc/commands/streams/link_to_multiple.rb', line 12

def call(stream_name, events, options:, &blk)
  result = []
  link_cmd = Commands::Streams::LinkTo.new(**connection_options)
  events.each.with_index do |event, index|
    response =
      link_cmd.call(stream_name, event, options: options) do |req_opts, proposed_msg_opts|
        req_opts.options.revision += index if has_revision_option?(req_opts.options)

        yield(req_opts, proposed_msg_opts) if blk
      end
    result.push(response)
    break if response.failure?
  end
  result
end