Class: Monga::Connections::FiberedProxyConnection
Constant Summary
EMProxyConnection::WAIT
Instance Method Summary
collapse
#find_server!, #initialize, #set_timeout, #timeout_happend
Instance Method Details
#send_command(msg, request_id = nil, &cb) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/monga/connections/fibered_proxy_connection.rb', line 8
def send_command(msg, request_id = nil, &cb)
if @timeout && @timeout > 0
@fib = Fiber.current
@requests[request_id] = [msg, @fib]
set_timeout
find_server!
res = Fiber.yield
raise res if Exception === res
conn = @client.aquire_connection
conn.send_command(msg, request_id, &cb)
else
error = Monga::Exceptions::Disconnected.new "Can't find appropriate server (all disconnected)"
cb.call(error) if cb
end
end
|
#server_found! ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/monga/connections/fibered_proxy_connection.rb', line 24
def server_found!
@pending_server = false
@pending_timeout.cancel if @pending_timeout
@pending_timeout = nil
@requests.keys.each do |req_id|
msg, fib = @requests.delete req_id
fib.call
end
end
|
#type ⇒ Object
4
5
6
|
# File 'lib/monga/connections/fibered_proxy_connection.rb', line 4
def type
:sync
end
|