redis_ring_client 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis_ring_client (0.0.4)
4
+ redis_ring_client (0.1.0)
5
5
  json
6
6
  redis
7
7
  zookeeper
@@ -42,17 +42,26 @@ module RedisRing
42
42
  end
43
43
 
44
44
  def get_shards_json_string(retries = 0)
45
- @zookeeper ||= Zookeeper.new(zookeeper_addr)
45
+ @zookeeper ||= self.class.zookeeper(zookeeper_addr)
46
46
  @watcher = Zookeeper::WatcherCallback.new
47
47
  resp = @zookeeper.get(:path => "/cluster_status", :watcher => @watcher, :watcher_context => "/cluster_status")
48
48
  return resp[:data]
49
49
  rescue ZookeeperExceptions::ZookeeperException::ConnectionClosed
50
50
  raise if retries == 4
51
- puts "reopening"
52
51
  @zookeeper.reopen
53
52
  return get_shards_json_string(retries + 1)
54
53
  end
55
54
 
55
+ def self.zookeepers
56
+ @zookeepers ||= {}
57
+ end
58
+
59
+ # it appears that only a very limited number of zookeeper connections can be opened by a single client
60
+ # so we have to cache/share them between RingMetaData instances
61
+ def self.zookeeper(address)
62
+ self.zookeepers[address] ||= Zookeeper.new(address)
63
+ end
64
+
56
65
  end
57
66
 
58
67
  class ShardMetaData
@@ -1,5 +1,5 @@
1
1
  module RedisRing
2
2
  module Client
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -36,11 +36,8 @@ describe RedisRing::Client::RingProxy do
36
36
  end
37
37
 
38
38
  context "with real RedisRing" do
39
- before(:all) do
40
- @proxy = RedisRing::Client::RingProxy.new
41
- end
42
-
43
39
  before(:each) do
40
+ @proxy = RedisRing::Client::RingProxy.new
44
41
  @proxy.flushdb
45
42
  end
46
43
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Pohorecki