Parent

Class Index [+]

Quicksearch

MessagePack::RPC::TCPClientTransport

Public Class Methods

new(session, address, reconnect_limit) click to toggle source
    # File lib/msgpack/rpc/transport/tcp.rb, line 62
62:         def initialize(session, address, reconnect_limit)
63:                 @session = session
64:                 @address = address
65: 
66:                 @pending = ""
67:                 @sockpool = []
68:                 @connecting = 0
69:                 @reconnect_limit = reconnect_limit
70:         end

Public Instance Methods

close() click to toggle source

ClientTransport interface

    # File lib/msgpack/rpc/transport/tcp.rb, line 89
89:         def close
90:                 @sockpool.reject! {|sock|
91:                         sock.detach if sock.attached?
92:                         sock.close
93:                         true
94:                 }
95:                 @sockpool = []
96:                 @connecting = 0
97:                 @pending = ""
98:                 self
99:         end
on_close(sock) click to toggle source

from TCPClientTransport::ClientSocket::on_close

     # File lib/msgpack/rpc/transport/tcp.rb, line 122
122:         def on_close(sock)
123:                 @sockpool.delete(sock)
124:         end
on_connect(sock) click to toggle source

from TCPClientTransport::ClientSocket::on_connect

     # File lib/msgpack/rpc/transport/tcp.rb, line 102
102:         def on_connect(sock)
103:                 @sockpool.push(sock)
104:                 sock.send_pending(@pending)
105:                 @pending = ""
106:                 @connecting = 0
107:         end
on_connect_failed(sock) click to toggle source

from TCPClientTransport::ClientSocket::on_connect_failed

     # File lib/msgpack/rpc/transport/tcp.rb, line 110
110:         def on_connect_failed(sock)
111:                 if @connecting < @reconnect_limit
112:                         try_connect
113:                         @connecting += 1
114:                 else
115:                         @connecting = 0
116:                         @pending = ""
117:                         @session.on_connect_failed
118:                 end
119:         end
send_data(data) click to toggle source

ClientTransport interface

    # File lib/msgpack/rpc/transport/tcp.rb, line 73
73:         def send_data(data)
74:                 if @sockpool.empty?
75:                         if @connecting == 0
76:                                 try_connect
77:                                 @connecting = 1
78:                         end
79:                         @pending << data
80:                 else
81:                         # FIXME pesudo connection load balance
82:                         # sock = @sockpool.choice
83:                         sock = @sockpool.first
84:                         sock.send_data(data)
85:                 end
86:         end

Private Instance Methods

try_connect() click to toggle source
     # File lib/msgpack/rpc/transport/tcp.rb, line 127
127:         def try_connect
128:                 host, port = *@address
129:                 sock = ClientSocket.connect(host, port, self, @session)  # async connect
130:                 @session.loop.attach(sock)
131:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.