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.
@@ -16,23 +16,28 @@ class MultiThink::Connection
16
16
  end
17
17
 
18
18
  def connect
19
- # TODO try all servers until we get a connection
20
- options = @servers.first
21
- begin
22
- @conn = r.connect(options)
23
- rescue
24
- @tried ||= 0
25
- sleep 1
26
- retry if (@tried += 1) < @retries
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
 
@@ -1,3 +1,3 @@
1
1
  class MultiThink
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multithink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: