File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ module Connection
9
9
class RedisClient < EventMachine ::Connection
10
10
include EventMachine ::Deferrable
11
11
12
+ attr_accessor :timeout
13
+
12
14
def post_init
13
15
@req = nil
14
16
@connected = false
@@ -44,6 +46,9 @@ def receive_data(data)
44
46
45
47
def read
46
48
@req = EventMachine ::DefaultDeferrable . new
49
+ if @timeout > 0
50
+ @req . timeout ( @timeout , :timeout )
51
+ end
47
52
EventMachine ::Synchrony . sync @req
48
53
end
49
54
@@ -96,7 +101,7 @@ def connected?
96
101
end
97
102
98
103
def timeout = ( timeout )
99
- @timeout = timeout
104
+ @connection . timeout = timeout
100
105
end
101
106
102
107
def disconnect
@@ -115,6 +120,8 @@ def read
115
120
payload
116
121
elsif type == :error
117
122
raise payload
123
+ elsif type == :timeout
124
+ raise TimeoutError
118
125
else
119
126
raise "Unknown type #{ type . inspect } "
120
127
end
You can’t perform that action at this time.
0 commit comments