rabbitmq-cluster 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,8 +21,11 @@ module RabbitMQ::Cluster
21
21
  end
22
22
 
23
23
  def register(node_name)
24
- key = "/rabbitmq/nodes/#{node_name}"
25
- client.set(key, node_name) unless client.exists?(key)
24
+ client.set(key_for(node_name), node_name) unless client.exists?(key_for(node_name))
25
+ end
26
+
27
+ def deregister(node_name)
28
+ client.delete(key_for(node_name))
26
29
  end
27
30
 
28
31
  def erlang_cookie
@@ -35,5 +38,11 @@ module RabbitMQ::Cluster
35
38
  erlang_cookie
36
39
  )
37
40
  end
41
+
42
+ private
43
+
44
+ def key_for(node_name)
45
+ "/rabbitmq/nodes/#{node_name}"
46
+ end
38
47
  end
39
48
  end
@@ -31,7 +31,7 @@ module RabbitMQ::Cluster
31
31
  etcd.aquire_lock do
32
32
  stopped_nodes.each do |node|
33
33
  `rabbitmqctl forget_cluster_node #{node['name']}`
34
- etcd.delete("/rabbitmq/nodes/#{node['name']}")
34
+ etcd.deregister(node['name'])
35
35
  end
36
36
  end
37
37
  end
@@ -1,5 +1,5 @@
1
1
  module RabbitMQ
2
2
  module Cluster
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -55,6 +55,14 @@ describe RabbitMQ::Cluster::Etcd do
55
55
  end
56
56
  end
57
57
 
58
+ describe '#deregister' do
59
+ it 'deletes the correct key' do
60
+ expect(etcd_client).to receive(:delete)
61
+ .with('/rabbitmq/nodes/rabbit@foobah')
62
+ subject.deregister('rabbit@foobah')
63
+ end
64
+ end
65
+
58
66
  describe '#erlang_cookie' do
59
67
  let(:erlang_cookie) { 'afbdgCVB23423bh324h' }
60
68
  before do
@@ -208,7 +208,7 @@ describe RabbitMQ::Cluster::Server do
208
208
  {"name" => "rabbit@node2", "running" => false}
209
209
  ])
210
210
  allow(subject).to receive(:"`")
211
- allow(etcd).to receive(:delete)
211
+ allow(etcd).to receive(:deregister)
212
212
  end
213
213
 
214
214
  it 'aquires the lock before doing anything' do
@@ -223,8 +223,8 @@ describe RabbitMQ::Cluster::Server do
223
223
  end
224
224
 
225
225
  it 'removes the stopped node from etcd' do
226
- expect(etcd).to receive(:delete)
227
- .with('/rabbitmq/nodes/rabbit@node2')
226
+ expect(etcd).to receive(:deregister)
227
+ .with('rabbit@node2')
228
228
  subject.synchronize
229
229
  end
230
230
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbitmq-cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: 3573058060397860240
147
+ hash: -4211619239378065739
148
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  segments:
155
155
  - 0
156
- hash: 3573058060397860240
156
+ hash: -4211619239378065739
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 1.8.25