multithink 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/multithink/connection.rb +15 -10
- data/lib/multithink/version.rb +1 -1
- metadata +1 -1
@@ -16,23 +16,28 @@ class MultiThink::Connection
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def connect
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
@tried = 0
|
20
|
+
while @tried < @retries do
|
21
|
+
@servers.each do |server|
|
22
|
+
begin
|
23
|
+
@conn = r.connect(server)
|
24
|
+
return true
|
25
|
+
rescue
|
26
|
+
sleep 1
|
27
|
+
end
|
28
|
+
end
|
27
29
|
end
|
30
|
+
# If we got here we couldn't get a connection. :(
|
31
|
+
raise RuntimeError "Error: Reached maximum retries (#{@retries})"
|
28
32
|
end
|
29
33
|
|
30
34
|
def run(query)
|
31
|
-
# TODO handle connection failure
|
32
35
|
begin
|
33
36
|
query.run(@conn)
|
34
37
|
rescue RuntimeError => e
|
35
|
-
reconnect
|
38
|
+
if reconnect
|
39
|
+
retry
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
data/lib/multithink/version.rb
CHANGED