Method: GRPC::ActiveCall#client_streamer

Defined in:
src/ruby/lib/grpc/generic/active_call.rb

#client_streamer(requests, metadata: {}) ⇒ Object

client_streamer sends a stream of requests to a GRPC server, and returns a single response.

requests provides an ‘iterable’ of Requests. I.e. it follows Ruby’s #each enumeration protocol. In the simplest case, requests will be an array of marshallable objects; in typical case it will be an Enumerable that allows dynamic construction of the marshallable objects.

a list, multiple metadata for its key are sent

Parameters:

  • requests (Object)

    an Enumerable of requests to send

  • metadata (Hash) (defaults to: {})

    metadata to be sent to the server. If a value is

Returns:

  • (Object)

    the response received from the server



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'src/ruby/lib/grpc/generic/active_call.rb', line 399

def client_streamer(requests, metadata: {})
  raise_error_if_already_executed
  begin
    ()
    requests.each { |r| @call.run_batch(SEND_MESSAGE => @marshal.call(r)) }
  rescue GRPC::Core::CallError => e
    receive_and_check_status # check for Cancelled
    raise e
  rescue => e
    set_input_stream_done
    raise e
  ensure
    set_output_stream_done
  end

  batch_result = @call.run_batch(
    SEND_CLOSE_FROM_CLIENT => nil,
    RECV_INITIAL_METADATA => nil,
    RECV_MESSAGE => nil,
    RECV_STATUS_ON_CLIENT => nil
  )

  set_input_stream_done

  @call. = batch_result.
  attach_status_results_and_complete_call(batch_result)
  get_message_from_batch_result(batch_result)
end