iproto 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- data/iproto.gemspec +1 -1
- data/lib/iproto/tcp_socket.rb +9 -2
- data/lib/iproto.rb +1 -1
- metadata +1 -1
data/iproto.gemspec
CHANGED
data/lib/iproto/tcp_socket.rb
CHANGED
@@ -26,7 +26,7 @@ module IProto
|
|
26
26
|
|
27
27
|
def could_be_connected?
|
28
28
|
@socket ? @socket != :disconnected
|
29
|
-
: (@
|
29
|
+
: (@reconnect || @reconnect_time < Time.now)
|
30
30
|
end
|
31
31
|
|
32
32
|
def socket
|
@@ -38,7 +38,11 @@ module IProto
|
|
38
38
|
end
|
39
39
|
sock
|
40
40
|
rescue Errno::ECONNREFUSED => e
|
41
|
-
|
41
|
+
unless @reconnect
|
42
|
+
@socket = :disconnected
|
43
|
+
else
|
44
|
+
@reconnect_time = Time.now + @reconnect_timeout
|
45
|
+
end
|
42
46
|
raise CouldNotConnect, e
|
43
47
|
end
|
44
48
|
|
@@ -46,6 +50,9 @@ module IProto
|
|
46
50
|
|
47
51
|
# begin ConnectionAPI
|
48
52
|
def send_request(request_type, body)
|
53
|
+
unless could_be_connected?
|
54
|
+
raise Disconnected, "connection is closed"
|
55
|
+
end
|
49
56
|
begin
|
50
57
|
request_id = next_request_id
|
51
58
|
socket.send pack_request(request_type, request_id, body), 0
|
data/lib/iproto.rb
CHANGED