class TestTarget

A runnable implementation of the schema-specified testing service, with each service method implemented as required by the interop testing spec.

Public Instance Methods

empty_call(_empty, _call) click to toggle source
# File src/ruby/pb/test/server.rb, line 175
def empty_call(_empty, _call)
  Empty.new
end
full_duplex_call(reqs, _call) click to toggle source
# File src/ruby/pb/test/server.rb, line 201
def full_duplex_call(reqs, _call)
  maybe_echo_metadata(_call)
  # reqs is a lazy Enumerator of the requests sent by the client.
  FullDuplexEnumerator.new(reqs).each_item
end
half_duplex_call(reqs) click to toggle source
# File src/ruby/pb/test/server.rb, line 207
def half_duplex_call(reqs)
  # TODO: update with unique behaviour of the half_duplex_call if that's
  # ever required by any of the tests.
  full_duplex_call(reqs)
end
streaming_input_call(call) click to toggle source
# File src/ruby/pb/test/server.rb, line 187
def streaming_input_call(call)
  sizes = call.each_remote_read.map { |x| x.payload.body.length }
  sum = sizes.inject(0) { |s, x| s + x }
  StreamingInputCallResponse.new(aggregated_payload_size: sum)
end
streaming_output_call(req, _call) click to toggle source
# File src/ruby/pb/test/server.rb, line 193
def streaming_output_call(req, _call)
  cls = StreamingOutputCallResponse
  req.response_parameters.map do |p|
    cls.new(payload: Payload.new(type: req.response_type,
                                 body: nulls(p.size)))
  end
end
unary_call(simple_req, _call) click to toggle source
# File src/ruby/pb/test/server.rb, line 179
def unary_call(simple_req, _call)
  maybe_echo_metadata(_call)
  maybe_echo_status_and_message(simple_req)
  req_size = simple_req.response_size
  SimpleResponse.new(payload: Payload.new(type: :COMPRESSABLE,
                                          body: nulls(req_size)))
end