class RPCBench::GRPC::Client

Public Class Methods

new(opts) click to toggle source
# File lib/rpc_bench/driver_grpc.rb, line 42
def initialize opts
  @opts = opts
end

Public Instance Methods

send_request(data, count) click to toggle source
# File lib/rpc_bench/driver_grpc.rb, line 58
def send_request(data, count)
  stub = RPCBench::GRPC::Calc::Stub.new("#{@opts[:host]}:#{@opts[:port]}", :this_channel_is_insecure)
  
  results = []
  (1..count).each do |_|
    results << sendmsg(stub, data)
  end

  results
end
sendmsg(stub, data) click to toggle source
# File lib/rpc_bench/driver_grpc.rb, line 46
def sendmsg stub, data
  begin
    stub.calc_tmp(RPCBench::GRPC::TmpRequest.new(num: data)).num
  rescue ::GRPC::BadStatus => e
    if(e.code == 8)
      sendmsg stub, data
    else
      puts "[warning] other error is occurrs"
    end
  end
end