Class: RPCBench::ZeroMQ::Client
- Defined in:
- lib/rpc_bench/driver_zmq.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(opts) ⇒ Client
constructor
A new instance of Client.
- #send_request(data, count) ⇒ Object
Methods inherited from Driver
Constructor Details
#initialize(opts) ⇒ Client
Returns a new instance of Client.
12 13 14 |
# File 'lib/rpc_bench/driver_zmq.rb', line 12 def initialize opts super opts end |
Instance Method Details
#close ⇒ Object
36 37 38 |
# File 'lib/rpc_bench/driver_zmq.rb', line 36 def close @context.terminate end |
#send_request(data, count) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rpc_bench/driver_zmq.rb', line 16 def send_request data, count sock = @context.socket(ZMQ::REQ) sock.connect("tcp://#{@opts[:host]}:#{@opts[:port]}") results = [] (1..count).each do |_| # sending request sock.send_string data.to_s # receiving reply reply = '' sock.recv_string(reply) results << reply.slice(/[0-9]+/).to_i end sock.close results end |