Class | Thrift::EventMachineTransport |
In: |
lib/thrift_client/event_machine.rb
lib/thrift_client/event_machine.rb |
Parent: | BaseTransport |
# File lib/thrift_client/event_machine.rb, line 10 10: def initialize(host, port=9090, timeout=5) 11: @host, @port, @timeout = host, port, timeout 12: @connection = nil 13: end
# File lib/thrift_client/event_machine.rb, line 10 10: def initialize(host, port=9090, timeout=5) 11: @host, @port, @timeout = host, port, timeout 12: @connection = nil 13: end
# File lib/thrift_client/event_machine.rb, line 19 19: def open 20: fiber = Fiber.current 21: @connection = EventMachineConnection.connect(@host, @port, @timeout) 22: @connection.callback do 23: fiber.resume 24: end 25: @connection.errback do 26: fiber.resume 27: end 28: Fiber.yield 29: 30: raise Thrift::TransportException, "Unable to connect to #{@host}:#{@port}" unless @connection.connected? 31: @connection 32: end
# File lib/thrift_client/event_machine.rb, line 19 19: def open 20: fiber = Fiber.current 21: @connection = EventMachineConnection.connect(@host, @port, @timeout) 22: @connection.callback do 23: fiber.resume 24: end 25: @connection.errback do 26: fiber.resume 27: end 28: Fiber.yield 29: 30: raise Thrift::TransportException, "Unable to connect to #{@host}:#{@port}" unless @connection.connected? 31: @connection 32: end
# File lib/thrift_client/event_machine.rb, line 15 15: def open? 16: @connection && @connection.connected? 17: end
# File lib/thrift_client/event_machine.rb, line 15 15: def open? 16: @connection && @connection.connected? 17: end
# File lib/thrift_client/event_machine.rb, line 38 38: def read(sz) 39: @connection.blocking_read(sz) 40: end
# File lib/thrift_client/event_machine.rb, line 38 38: def read(sz) 39: @connection.blocking_read(sz) 40: end
# File lib/thrift_client/event_machine.rb, line 42 42: def write(buf) 43: @connection.send_data(buf) 44: end