rabbitmq-cluster 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  require "rabbitmq/cluster/version"
2
- require "rabbitmq/cluster/etcd"
3
2
  require "rabbitmq/cluster/server"
4
3
 
5
4
  module RabbitMQ
@@ -5,6 +5,12 @@ module RabbitMQ::Cluster
5
5
  attr_accessor :client
6
6
  private :client
7
7
 
8
+ def self.build
9
+ new(
10
+ ::Etcd::Client.new(uri: ENV['ETCD_HOST'])
11
+ )
12
+ end
13
+
8
14
  def initialize(client)
9
15
  self.client = client
10
16
  client.connect
@@ -1,4 +1,5 @@
1
1
  require 'rabbitmq_manager'
2
+ require "rabbitmq/cluster/etcd"
2
3
 
3
4
  class RabbitMQManager
4
5
  def aliveness_test(vhost)
@@ -13,10 +14,8 @@ module RabbitMQ::Cluster
13
14
 
14
15
  def self.build
15
16
  new(
16
- RabbitMQManager.new(ENV['RABBITMQ_MNGR'] || 'http://guest:guest@localhost:15672'),
17
- RabbitMQ::Cluster::Etcd.new(
18
- Etcd::Client.new(uri: ENV['ETCD_HOST'])
19
- )
17
+ ::RabbitMQManager.new(ENV['RABBITMQ_MNGR'] || 'http://guest:guest@localhost:15672'),
18
+ ::RabbitMQ::Cluster::Etcd.build
20
19
  )
21
20
  end
22
21
 
@@ -1,5 +1,5 @@
1
1
  module RabbitMQ
2
2
  module Cluster
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -4,6 +4,17 @@ describe RabbitMQ::Cluster::Etcd do
4
4
  let(:etcd_client) { double(:etcd, connect: true) }
5
5
  subject { described_class.new(etcd_client) }
6
6
 
7
+ describe '.build' do
8
+ before do
9
+ allow(Etcd::Client).to receive(:new).and_return(etcd_client)
10
+ end
11
+
12
+ it 'sets up an instance' do
13
+ expect(described_class).to receive(:new).with(etcd_client)
14
+ described_class.build
15
+ end
16
+ end
17
+
7
18
  describe '#nodes' do
8
19
  it 'returns the list of nodes registed in etcd' do
9
20
  allow(etcd_client).to receive(:get).with('/rabbitmq/nodes').and_return(
@@ -6,6 +6,18 @@ describe RabbitMQ::Cluster::Server do
6
6
 
7
7
  subject { described_class.new(client, etcd) }
8
8
 
9
+ describe '.build' do
10
+ before do
11
+ allow(RabbitMQ::Cluster::Etcd).to receive(:build).and_return(etcd)
12
+ allow(RabbitMQManager).to receive(:new).and_return(client)
13
+ end
14
+
15
+ it 'sets up an instance' do
16
+ expect(described_class).to receive(:new).with(client, etcd)
17
+ described_class.build
18
+ end
19
+ end
20
+
9
21
  describe '#name' do
10
22
  let(:client) do
11
23
  double(
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.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  segments:
148
148
  - 0
149
- hash: -1898050737678359289
149
+ hash: 770618519308933099
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements:
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  segments:
157
157
  - 0
158
- hash: -1898050737678359289
158
+ hash: 770618519308933099
159
159
  requirements: []
160
160
  rubyforge_project:
161
161
  rubygems_version: 1.8.25