msgr 0.11.0.rc2 → 0.11.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1702792de09a7bdb79ac0cc05e7cdc89e00ed8ed
4
- data.tar.gz: 138ef85e022e7346efc4e2960002c0b2f8bc3a62
3
+ metadata.gz: 0edffc091410f7c6c9a9bf2e1790ec2a2b6054f2
4
+ data.tar.gz: 23edf10a838aa69bc79dfdc7ba22633eaf46921d
5
5
  SHA512:
6
- metadata.gz: 3683e6cdcf37754eb553ceaa6db9c40c0837dd48b2702a619a6639a76a4ecc72d6f044bfa2c8cf26e856d1a47d55aa1471bd8896390fdcf9930ddf1358de4c29
7
- data.tar.gz: fc5e451ecd1b6f983ea41f5b6ba06970186183f5efc178e17a071edb50f7346059f80c73d660e5eacd8edfb9e0af206b9b192b659eed26c5ae96b11aff815cf9
6
+ metadata.gz: 2eee451a47c451ba9e5566d9b5e1ad08bbcf829f3299693cc8e36639aa93dcc89a03a9d5b250ab65fe630f36672e87d4ef78285c1ec05373549d31dde63ce7fe
7
+ data.tar.gz: 3cbcf7b04c4f164ff1e6fd0631aa1c9e78b50f52e17c91d468b0c5df85ed5e4a2fff970aeec599a7c6269a57d70a60665d146d79d773cfc135aac8058c7d613c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.rc3
4
+
5
+ * Define pool_class by string to make it useable with rails
6
+ * Add checkcredentials config option to disable initial connect to rabbitmq
7
+ server to check the credentials
8
+
3
9
  ## 0.11.rc2
4
10
 
5
11
  * Add nack for messages when an error is rescued by dispatcher
@@ -12,10 +12,10 @@ module Msgr
12
12
  attr_reader :pool
13
13
 
14
14
  def initialize(config)
15
- log(:info) { "Initialize new dispatcher (#{config[:max]} threads)..." }
15
+ config[:pool_class] ||= 'Concurrent::CachedThreadPool'
16
+ log(:info) { "Initialize new dispatcher (#{config[:pool_class]} with #{config[:max]} threads)..." }
16
17
 
17
- config[:pool_class] ||= ::Concurrent::CachedThreadPool
18
- @pool = config[:pool_class].new(max: config[:max])
18
+ @pool = config[:pool_class].constantize.new(max: config[:max])
19
19
  end
20
20
 
21
21
  def call(message)
data/lib/msgr/railtie.rb CHANGED
@@ -27,8 +27,8 @@ module Msgr
27
27
  return unless cfg # no config given -> does not load Msgr
28
28
 
29
29
  Msgr.config = cfg
30
- Msgr.client.connect
31
- Msgr.start if !cfg[:autostart].nil? && cfg[:autostart]
30
+ Msgr.client.connect if cfg[:checkcredentials]
31
+ Msgr.start if cfg[:autostart]
32
32
  end
33
33
 
34
34
  def parse_config(cfg)
@@ -56,6 +56,15 @@ module Msgr
56
56
  raise ArgumentError, "Invalid value for rabbitmq config autostart: \"#{cfg[:autostart]}\""
57
57
  end
58
58
 
59
+ case cfg[:checkcredentials]
60
+ when true, 'true', 'enabled', nil
61
+ cfg[:checkcredentials] = true
62
+ when false, 'false', 'disabled'
63
+ cfg[:checkcredentials] = false
64
+ else
65
+ raise ArgumentError, "Invalid value for rabbitmq config checkcredentials: \"#{cfg[:checkcredentials]}\""
66
+ end
67
+
59
68
  cfg[:routing_file] ||= Rails.root.join('config/msgr.rb').to_s
60
69
  cfg
61
70
  end
data/lib/msgr/version.rb CHANGED
@@ -3,7 +3,7 @@ module Msgr
3
3
  MAJOR = 0
4
4
  MINOR = 11
5
5
  PATCH = 0
6
- STAGE = 'rc2'
6
+ STAGE = 'rc3'
7
7
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
8
8
 
9
9
  def self.to_s; STRING end
@@ -28,7 +28,7 @@ class NullPool
28
28
  end
29
29
 
30
30
  @client = Msgr::Client.new user: 'guest', password: 'guest',
31
- max: 4#, pool_class: NullPool
31
+ max: 4#, pool_class: 'NullPool'
32
32
 
33
33
  @client.routes.configure do
34
34
  route 'abc.#', to: 'test#index'
@@ -29,6 +29,12 @@ describe Msgr::Railtie do
29
29
 
30
30
  it { should raise_error 'Invalid value for rabbitmq config autostart: "unvalid"'}
31
31
  end
32
+
33
+ context 'with invalid checkcredentials value' do
34
+ let(:settings) { {"test" => { uri: 'hans', checkcredentials: 'unvalid'}} }
35
+
36
+ it { should raise_error 'Invalid value for rabbitmq config checkcredentials: "unvalid"'}
37
+ end
32
38
  end
33
39
 
34
40
  context 'without set routes file' do
@@ -78,5 +84,21 @@ describe Msgr::Railtie do
78
84
  Msgr::Railtie.load config
79
85
  end
80
86
  end
87
+
88
+ context 'without checkcredentials value' do
89
+ it 'should connect to rabbitmq directly to check credentials' do
90
+ expect_any_instance_of(Msgr::Client).to receive(:connect)
91
+ expect(Msgr::Railtie).to receive(:load_config).and_return({ "test" => { uri: 'test' } })
92
+ Msgr::Railtie.load config
93
+ end
94
+ end
95
+
96
+ context 'with checkcredentials is false' do
97
+ it 'should connect to rabbitmq directly to check credentials' do
98
+ expect_any_instance_of(Msgr::Client).to_not receive(:connect)
99
+ expect(Msgr::Railtie).to receive(:load_config).and_return({ "test" => { uri: 'test', checkcredentials: false } })
100
+ Msgr::Railtie.load config
101
+ end
102
+ end
81
103
  end
82
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0.rc2
4
+ version: 0.11.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-29 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: 1.3.1
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.2.2
192
+ rubygems_version: 2.2.0
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: 'Msgr: Rails-like Messaging Framework'