Object
SessionPool is usable for connection pooling. You can get pooled Session using get_session method. Note that SessionPool includes LoopUtil.
initialize(builder, loop = Loop.new)
initialize(loop = Loop.new)
Creates an SessionPool.
# File lib/msgpack/rpc/session_pool.rb, line 30 30: def initialize(arg1=nil, arg2=nil) 31: if arg1.respond_to?(:build_transport) 32: # 1. 33: builder = arg1 34: loop = arg2 || Loop.new 35: else 36: # 2. 37: builder = TCPTransport.new 38: loop = arg1 || Loop.new 39: end 40: 41: @builder = builder 42: @loop = loop 43: @pool = {} 44: 45: @timer = Timer.new(1, true, &method(:step_timeout)) 46: loop.attach(@timer) 47: end
# File lib/msgpack/rpc/session_pool.rb, line 72 72: def close 73: @pool.reject! {|addr, s| 74: s.close 75: true 76: } 77: @timer.detach if @timer.attached? 78: nil 79: end
get_session(address)
get_session(host, port)
Returns pooled Session. If there are no pooled Session for the specified address, this method creates the Session and pools it.
# File lib/msgpack/rpc/session_pool.rb, line 55 55: def get_session(arg1, arg2=nil) 56: if arg2.nil? 57: # 1. 58: addr = arg1 59: else 60: # 2. 61: host = arg1 62: port = arg2 63: addr = Address.new(host, port) 64: end 65: 66: @pool[addr] ||= Session.new(@builder, addr, @loop) 67: end
backward compatibility
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.