Parent

Included Modules

Class Index [+]

Quicksearch

MessagePack::RPC::SessionPool

SessionPool is usable for connection pooling. You can get pooled Session using get_session method. Note that SessionPool includes LoopUtil.

Public Class Methods

new(arg1=nil, arg2=nil) click to toggle source
  1. initialize(builder, loop = Loop.new)

  2. 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

Public Instance Methods

close() click to toggle source
    # 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(arg1, arg2=nil) click to toggle source
  1. get_session(address)

  2. 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
Also aliased as: get_session_addr
get_session_addr(arg1, arg2=nil) click to toggle source

backward compatibility

Alias for: get_session

Private Instance Methods

step_timeout() click to toggle source
    # File lib/msgpack/rpc/session_pool.rb, line 84
84:         def step_timeout
85:                 @pool.each_pair {|addr,s| s.step_timeout }
86:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.