message-driver 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -2
  3. data/.rubocop_todo.yml +15 -23
  4. data/.travis.yml +10 -22
  5. data/CHANGELOG.md +9 -0
  6. data/Gemfile +34 -24
  7. data/Guardfile +46 -29
  8. data/LICENSE +1 -1
  9. data/Rakefile +14 -6
  10. data/features/CHANGELOG.md +1 -0
  11. data/features/step_definitions/logging_steps.rb +3 -2
  12. data/features/support/firewall_helper.rb +2 -2
  13. data/features/support/no_error_matcher.rb +1 -1
  14. data/lib/message_driver/adapters/base.rb +115 -11
  15. data/lib/message_driver/adapters/bunny_adapter.rb +58 -46
  16. data/lib/message_driver/adapters/in_memory_adapter.rb +57 -35
  17. data/lib/message_driver/adapters/stomp_adapter.rb +10 -10
  18. data/lib/message_driver/broker.rb +16 -19
  19. data/lib/message_driver/client.rb +3 -7
  20. data/lib/message_driver/destination.rb +4 -4
  21. data/lib/message_driver/message.rb +3 -2
  22. data/lib/message_driver/middleware/block_middleware.rb +1 -1
  23. data/lib/message_driver/subscription.rb +1 -1
  24. data/lib/message_driver/version.rb +1 -1
  25. data/message-driver.gemspec +6 -6
  26. data/spec/integration/bunny/amqp_integration_spec.rb +6 -4
  27. data/spec/integration/bunny/bunny_adapter_spec.rb +1 -3
  28. data/spec/integration/in_memory/in_memory_adapter_spec.rb +46 -6
  29. data/spec/integration/stomp/stomp_adapter_spec.rb +0 -2
  30. data/spec/spec_helper.rb +6 -0
  31. data/spec/support/matchers/override_method_matcher.rb +7 -0
  32. data/spec/support/shared/adapter_examples.rb +3 -0
  33. data/spec/support/shared/client_ack_examples.rb +26 -4
  34. data/spec/support/shared/context_examples.rb +46 -0
  35. data/spec/support/shared/destination_examples.rb +28 -0
  36. data/spec/support/shared/subscription_examples.rb +6 -1
  37. data/spec/support/shared/transaction_examples.rb +35 -4
  38. data/spec/support/test_adapter.rb +19 -0
  39. data/spec/support/utils.rb +1 -5
  40. data/spec/units/message_driver/adapters/base_spec.rb +37 -31
  41. data/spec/units/message_driver/broker_spec.rb +1 -2
  42. data/spec/units/message_driver/client_spec.rb +3 -3
  43. data/spec/units/message_driver/destination_spec.rb +4 -2
  44. data/spec/units/message_driver/message_spec.rb +9 -3
  45. data/test_lib/broker_config.rb +0 -2
  46. data/test_lib/provider/base.rb +2 -6
  47. data/test_lib/provider/rabbitmq.rb +3 -3
  48. metadata +18 -16
  49. data/ci/travis_setup +0 -7
  50. data/features/CHANGELOG.md +0 -102
@@ -150,7 +150,7 @@ module MessageDriver
150
150
  end
151
151
 
152
152
  it "raises and error if you don't provide a MessageDriver::Adapters::Base" do
153
- adapter = Hash.new
153
+ adapter = {}
154
154
 
155
155
  expect do
156
156
  described_class.new(adapter: adapter)
@@ -335,6 +335,5 @@ module MessageDriver
335
335
  end
336
336
  end
337
337
  end
338
-
339
338
  end
340
339
  end
@@ -174,7 +174,7 @@ module MessageDriver
174
174
  it 'calls rollback instead of commit and raises the error' do
175
175
  expect do
176
176
  subject.with_message_transaction do
177
- fail 'having a tough time'
177
+ raise 'having a tough time'
178
178
  end
179
179
  end.to raise_error 'having a tough time'
180
180
  expect(adapter_context).to have_received(:begin_transaction)
@@ -188,7 +188,7 @@ module MessageDriver
188
188
  allow(adapter_context).to receive(:rollback_transaction).and_raise('rollback failed!')
189
189
  expect do
190
190
  subject.with_message_transaction do
191
- fail 'having a tough time'
191
+ raise 'having a tough time'
192
192
  end
193
193
  end.to raise_error 'having a tough time'
194
194
  expect(logger).to have_received(:error).with(match('rollback failed!'))
@@ -212,7 +212,7 @@ module MessageDriver
212
212
  expect do
213
213
  subject.with_message_transaction do
214
214
  subject.with_message_transaction do
215
- fail 'having a tough time'
215
+ raise 'having a tough time'
216
216
  end
217
217
  end
218
218
  end.to raise_error 'having a tough time'
@@ -3,7 +3,9 @@ require 'spec_helper'
3
3
  module MessageDriver
4
4
  module Destination
5
5
  RSpec.describe Base do
6
- subject(:destination) { Base.new(nil, nil, nil, nil) }
6
+ let(:broker) { Broker.configure(:test, adapter: TestAdapter) }
7
+ let(:adapter) { broker.adapter }
8
+ subject(:destination) { Base.new(adapter, nil, nil, nil) }
7
9
 
8
10
  describe '#middlware' do
9
11
  it { expect(subject.middleware).to be_a Middleware::MiddlewareStack }
@@ -17,7 +19,7 @@ module MessageDriver
17
19
  expect do
18
20
  consumer = ->(_) {}
19
21
  destination.subscribe(&consumer)
20
- end.to raise_error "#subscribe is not supported by #{destination.class}"
22
+ end.to raise_error "#subscribe is not supported by #{TestAdapter}"
21
23
  end
22
24
  end
23
25
  end
@@ -8,14 +8,19 @@ module MessageDriver
8
8
  let(:headers) { { foo: :bar, bar: :baz } }
9
9
  let(:properties) { { persistent: true, client_ack: true } }
10
10
  let(:ctx) { double('adapter_context') }
11
+ let(:destination) { double('destination') }
11
12
 
12
13
  context 'sets the body, header and properites on initialization' do
13
- subject { described_class.new(ctx, body, headers, properties) }
14
+ subject { described_class.new(ctx, destination, body, headers, properties) }
14
15
 
15
16
  describe '#ctx' do
16
17
  it { expect(subject.ctx).to be(ctx) }
17
18
  end
18
19
 
20
+ describe '#destination' do
21
+ it { expect(subject.destination).to be(destination) }
22
+ end
23
+
19
24
  describe '#body' do
20
25
  it { expect(subject.body).to eq(body) }
21
26
  end
@@ -34,7 +39,7 @@ module MessageDriver
34
39
  end
35
40
 
36
41
  it 'can be provided in the constructor' do
37
- msg = described_class.new(ctx, body, headers, properties, 'my_raw_body')
42
+ msg = described_class.new(ctx, destination, body, headers, properties, 'my_raw_body')
38
43
 
39
44
  expect(msg.raw_body).to eq('my_raw_body')
40
45
  expect(msg.body).to eq(body)
@@ -45,8 +50,9 @@ module MessageDriver
45
50
 
46
51
  let(:logger) { MessageDriver.logger }
47
52
  let(:ctx) { double('adapter_context') }
53
+ let(:destination) { double('destination') }
48
54
  let(:options) { double('options') }
49
- subject(:message) { described_class.new(ctx, 'body', {}, {}) }
55
+ subject(:message) { described_class.new(ctx, destination, 'body', {}, {}) }
50
56
 
51
57
  describe '#ack' do
52
58
  before do
@@ -65,8 +65,6 @@ class BrokerConfig
65
65
  5672
66
66
  when :stomp
67
67
  61613
68
- else
69
- nil
70
68
  end
71
69
  end
72
70
  end
@@ -11,11 +11,7 @@ class BaseProvider
11
11
 
12
12
  def pause_if_needed(seconds = 0.1)
13
13
  seconds *= 10 if ENV['CI'] == 'true'
14
- case BrokerConfig.current_adapter
15
- when :in_memory
16
- else
17
- sleep seconds
18
- end
14
+ sleep seconds unless BrokerConfig.current_adapter == :in_memory
19
15
  end
20
16
 
21
17
  def fetch_messages(destination_name, _opts = {})
@@ -49,7 +45,7 @@ class BaseProvider
49
45
  when MessageDriver::Destination::Base
50
46
  destination
51
47
  else
52
- fail "didn't understand destination #{destination.inspect}"
48
+ raise "didn't understand destination #{destination.inspect}"
53
49
  end
54
50
  end
55
51
 
@@ -21,7 +21,7 @@ class RabbitmqProvider < BaseProvider
21
21
  if msg.nil?
22
22
  break
23
23
  else
24
- result << build_message(msg)
24
+ result << build_message(msg, destination)
25
25
  end
26
26
  end
27
27
  break if msgs.nil? || msgs.empty?
@@ -46,10 +46,10 @@ class RabbitmqProvider < BaseProvider
46
46
 
47
47
  private
48
48
 
49
- def build_message(data)
49
+ def build_message(data, destination)
50
50
  props = data.properties.dup
51
51
  headers = props.delete(:headers)
52
- MessageDriver::Message::Base.new(Context, data.payload, headers, props)
52
+ MessageDriver::Message::Base.new(Context, destination, data.payload, headers, props)
53
53
  end
54
54
 
55
55
  def vhost
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Campbell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.1.0
33
+ version: 3.5.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.1.0
40
+ version: 3.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cucumber
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "<"
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2'
47
+ version: 2.4.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "<"
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2'
54
+ version: 2.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: aruba
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "<"
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.9'
61
+ version: 0.14.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "<"
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.9'
68
+ version: 0.14.1
69
69
  description: Easy message queues for ruby using AMQ, STOMP and others
70
70
  email:
71
71
  - message-driver@soupmatt.com
@@ -88,7 +88,6 @@ files:
88
88
  - README.md
89
89
  - Rakefile
90
90
  - ci/reset_vhost
91
- - ci/travis_setup
92
91
  - examples/basic_producer_and_consumer/Gemfile
93
92
  - examples/basic_producer_and_consumer/common.rb
94
93
  - examples/basic_producer_and_consumer/consumer.rb
@@ -165,12 +164,14 @@ files:
165
164
  - spec/integration/in_memory/in_memory_adapter_spec.rb
166
165
  - spec/integration/stomp/stomp_adapter_spec.rb
167
166
  - spec/spec_helper.rb
167
+ - spec/support/matchers/override_method_matcher.rb
168
168
  - spec/support/shared/adapter_examples.rb
169
169
  - spec/support/shared/client_ack_examples.rb
170
170
  - spec/support/shared/context_examples.rb
171
171
  - spec/support/shared/destination_examples.rb
172
172
  - spec/support/shared/subscription_examples.rb
173
173
  - spec/support/shared/transaction_examples.rb
174
+ - spec/support/test_adapter.rb
174
175
  - spec/support/utils.rb
175
176
  - spec/units/message_driver/adapters/base_spec.rb
176
177
  - spec/units/message_driver/broker_spec.rb
@@ -198,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
199
  requirements:
199
200
  - - ">="
200
201
  - !ruby/object:Gem::Version
201
- version: 1.9.2
202
+ version: 1.9.3
202
203
  required_rubygems_version: !ruby/object:Gem::Requirement
203
204
  requirements:
204
205
  - - ">="
@@ -206,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
207
  version: '0'
207
208
  requirements: []
208
209
  rubyforge_project:
209
- rubygems_version: 2.4.5.1
210
+ rubygems_version: 2.5.2
210
211
  signing_key:
211
212
  specification_version: 4
212
213
  summary: Easy message queues for ruby
@@ -261,12 +262,14 @@ test_files:
261
262
  - spec/integration/in_memory/in_memory_adapter_spec.rb
262
263
  - spec/integration/stomp/stomp_adapter_spec.rb
263
264
  - spec/spec_helper.rb
265
+ - spec/support/matchers/override_method_matcher.rb
264
266
  - spec/support/shared/adapter_examples.rb
265
267
  - spec/support/shared/client_ack_examples.rb
266
268
  - spec/support/shared/context_examples.rb
267
269
  - spec/support/shared/destination_examples.rb
268
270
  - spec/support/shared/subscription_examples.rb
269
271
  - spec/support/shared/transaction_examples.rb
272
+ - spec/support/test_adapter.rb
270
273
  - spec/support/utils.rb
271
274
  - spec/units/message_driver/adapters/base_spec.rb
272
275
  - spec/units/message_driver/broker_spec.rb
@@ -277,4 +280,3 @@ test_files:
277
280
  - spec/units/message_driver/middleware/block_middleware_spec.rb
278
281
  - spec/units/message_driver/middleware/middleware_stack_spec.rb
279
282
  - spec/units/message_driver/subscription_spec.rb
280
- has_rdoc:
data/ci/travis_setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
-
3
- if [ "$ADAPTER" = "stomp" ]; then
4
- sudo rabbitmq-plugins enable rabbitmq_stomp
5
- sudo service rabbitmq-server restart
6
- sleep 3
7
- fi
@@ -1,102 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.6.1 - 2016-01-28
4
-
5
- * fix an issue that prevents gems built under ruby 2.3.0 to be installed
6
- under ruby 2.3.0 by rebuilding the gem under ruby 2.2
7
-
8
- ## 0.6.0 - 2016-01-28
9
-
10
- * official support for bunny 2.x
11
- * support ruby 2.3
12
- * drop support for bunny < 1.7
13
- * improved API documentation (still a WIP)
14
- * fix an issue with confirm_and_wait transactions erroring because there
15
- was no open channel
16
-
17
- ## 0.5.3 - 2014-10-23
18
-
19
- * In bunny adapter, avoid sending a tx_commit if we haven't done anything requiring
20
- a commit inside the transaction block.
21
-
22
- ## 0.5.2 - 2014-10-14
23
-
24
- * fix deprecation warning with bunny 1.5.0
25
-
26
- ## 0.5.1 - 2014-10-08
27
-
28
- * put version constant under correct module
29
-
30
- ## 0.5.0 - 2014-09-17
31
-
32
- * add support for checking consumer counts on a queue in bunny and in_memory adapters
33
- * in_memory adapter now supports multiple subscribers per queue, and does a round-robin
34
- through them when sending messages to consumers
35
- * upgrade to rspec 3
36
- * Middleware can now be used to automatically pre/post-process messages as they are published to
37
- or consumed from a destination
38
-
39
- ## 0.4.0 - 2014-07-03
40
-
41
- * require bunny 1.2.2 or later
42
- * add support for publish confirmations
43
-
44
- ## 0.3.0 - 2014-02-26
45
-
46
- * Support for handling multiple broker connections
47
- * require bunny 1.1.3 or later
48
- * make bunny connections as lazily initialized as possible
49
- * bunny transactions start lazily
50
-
51
- ## 0.2.2 - 2014-02-21
52
-
53
- * Lots of work on reconnection handling for bunny. Still a work in
54
- progress.
55
-
56
- ## 0.2.1 - 2013-11-13
57
-
58
- * Correct an issue in handling Bunny::ConnectionLevelErrors.
59
- Bunny::Session will now get properly restarted.
60
-
61
- ## 0.2.0 - 2013-11-05
62
-
63
- * drop support for bunny 0.9.x
64
- * add support for bunny 1.0.x
65
- * ability to create subscriptions from a block instead of having to
66
- register a consumer
67
-
68
- ## 0.2.0.rc2 - 2013-10-30
69
-
70
- * Features
71
- * Prefetch size for bunny consumers
72
- * Bugs
73
- * better error handling for transaction bunny consumers
74
-
75
- ## 0.2.0.rc1 - 2013-09-23
76
-
77
- * Features
78
- * Message Consumers, all different flavors
79
- * Bunny and InMemory adapters
80
- * Client Acks
81
- * Bunny adapter
82
- * Bunny adapter
83
- * much better connection and channel error handling, including
84
- reconnecting when broker becomes unreachable
85
- * Adapters
86
- * begin work on Stomp 1.1/1.2 adapter
87
-
88
- ## 0.1.0 - 2013-04-05
89
-
90
- Initial Release
91
-
92
- * Features
93
- * Publish a message
94
- * Broker transactions for publishing
95
- * Pop a message
96
- * named and dynamic destinations
97
- * message_count for destinations
98
- * Adapters
99
- * InMemory
100
- * #reset_after_test method for clearing out queues
101
- * Bunny (amqp 0.9)
102
- * handle connection and channel errors transparently