File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,19 @@ class RedisClient < EventMachine::Connection
10
10
11
11
def post_init
12
12
@req = nil
13
+ @connected = false
13
14
@reader = ::Hiredis ::Reader . new
14
15
end
15
16
16
17
def connection_completed
18
+ @connected = true
17
19
succeed
18
20
end
19
21
22
+ def connected?
23
+ @connected
24
+ end
25
+
20
26
def receive_data ( data )
21
27
@reader . feed ( data )
22
28
@@ -39,6 +45,7 @@ def send(data)
39
45
end
40
46
41
47
def unbind
48
+ @connected = false
42
49
if @req
43
50
@req . fail [ :error , Errno ::ECONNRESET ]
44
51
@req = nil
@@ -53,12 +60,11 @@ class Synchrony
53
60
54
61
def initialize
55
62
@timeout = 5_000_000
56
- @state = :disconnected
57
63
@connection = nil
58
64
end
59
65
60
66
def connected?
61
- @state == : connected
67
+ @connection && @connection . connected?
62
68
end
63
69
64
70
def timeout = ( usecs )
@@ -79,7 +85,6 @@ def connect_unix(path, timeout)
79
85
end
80
86
81
87
def disconnect
82
- @state = :disconnected
83
88
@connection . close_connection
84
89
@connection = nil
85
90
end
@@ -105,7 +110,6 @@ def read
105
110
def setup_connect_callbacks ( conn , f )
106
111
conn . callback do
107
112
@connection = conn
108
- @state = :connected
109
113
f . resume conn
110
114
end
111
115
You can’t perform that action at this time.
0 commit comments