redis_ring_client 0.1.1 → 0.1.2

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis_ring_client (0.1.0)
4
+ redis_ring_client (0.1.1)
5
5
  json
6
6
  redis
7
7
  zookeeper
@@ -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 => "/cluster_status", :watcher => @watcher, :watcher_context => "/cluster_status")
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
@@ -1,5 +1,5 @@
1
1
  module RedisRing
2
2
  module Client
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -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
- - 1
9
- version: 0.1.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-03-21 00:00:00 +01:00
17
+ date: 2011-04-11 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency