redis_ring_client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -5,10 +5,11 @@ module RedisRing
|
|
5
5
|
|
6
6
|
class RingMetaData
|
7
7
|
|
8
|
-
attr_reader :zookeeper_addr, :zookeeper
|
8
|
+
attr_reader :zookeeper_addr, :zookeeper, :cluster_name
|
9
9
|
|
10
|
-
def initialize(zookeeper_addr)
|
10
|
+
def initialize(zookeeper_addr, cluster_name)
|
11
11
|
@zookeeper_addr = zookeeper_addr
|
12
|
+
@cluster_name = cluster_name
|
12
13
|
end
|
13
14
|
|
14
15
|
def reload!
|
@@ -44,7 +45,7 @@ module RedisRing
|
|
44
45
|
def get_shards_json_string(retries = 0)
|
45
46
|
@zookeeper ||= self.class.zookeeper(zookeeper_addr)
|
46
47
|
@watcher = Zookeeper::WatcherCallback.new
|
47
|
-
resp = @zookeeper.get(:path => "
|
48
|
+
resp = @zookeeper.get(:path => "/#{cluster_name}_cluster_status", :watcher => @watcher, :watcher_context => "/#{cluster_name}/cluster_status")
|
48
49
|
return resp[:data]
|
49
50
|
rescue ZookeeperExceptions::ZookeeperException::ConnectionClosed
|
50
51
|
raise if retries == 4
|
@@ -154,6 +154,7 @@ module RedisRing
|
|
154
154
|
@zookeeper = opts[:zookeeper] || 'localhost:2181'
|
155
155
|
@db = opts[:db] || 0
|
156
156
|
@password = opts[:password]
|
157
|
+
@cluster_name = opts[:cluster_name] || 'redis-ring'
|
157
158
|
end
|
158
159
|
|
159
160
|
def connection_for_key(key)
|
@@ -174,7 +175,7 @@ module RedisRing
|
|
174
175
|
protected
|
175
176
|
|
176
177
|
def ring_meta_data
|
177
|
-
@ring_meta_data ||= RingMetaData.new(@zookeeper)
|
178
|
+
@ring_meta_data ||= RingMetaData.new(@zookeeper, @cluster_name)
|
178
179
|
end
|
179
180
|
|
180
181
|
def sharder
|
@@ -29,7 +29,7 @@ describe RedisRing::Client::RingMetaData do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should download json lazily" do
|
32
|
-
@metadata = RedisRing::Client::RingMetaData.new('localhost:2181')
|
32
|
+
@metadata = RedisRing::Client::RingMetaData.new('localhost:2181', 'some-name')
|
33
33
|
|
34
34
|
stub_zookeeper
|
35
35
|
|
@@ -40,7 +40,7 @@ describe RedisRing::Client::RingMetaData do
|
|
40
40
|
before(:each) do
|
41
41
|
stub_zookeeper
|
42
42
|
|
43
|
-
@metadata = RedisRing::Client::RingMetaData.new('localhost:2181')
|
43
|
+
@metadata = RedisRing::Client::RingMetaData.new('localhost:2181', 'some-name')
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should have ring_size of 10" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Adam Pohorecki
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-04-11 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|