message-driver 0.4.0 → 0.5.0

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.rubocop.yml +26 -2
  4. data/.rubocop_todo.yml +15 -123
  5. data/.travis.yml +2 -1
  6. data/CHANGELOG.md +10 -1
  7. data/Gemfile +15 -6
  8. data/Rakefile +23 -12
  9. data/ci/reset_vhost +8 -3
  10. data/ci/travis_setup +0 -3
  11. data/features/.nav +6 -1
  12. data/features/CHANGELOG.md +10 -1
  13. data/features/amqp_specific_features/binding_amqp_destinations.feature +1 -0
  14. data/features/amqp_specific_features/declaring_amqp_exchanges.feature +1 -0
  15. data/features/amqp_specific_features/server_named_destinations.feature +1 -0
  16. data/features/destination_metadata.feature +26 -0
  17. data/features/logging.feature +1 -1
  18. data/features/middleware/middleware_basics.feature +91 -0
  19. data/features/middleware/middleware_ordering.feature +60 -0
  20. data/features/middleware/middleware_parameters.feature +43 -0
  21. data/features/middleware/middleware_with_blocks.feature +85 -0
  22. data/features/step_definitions/dynamic_destinations_steps.rb +1 -1
  23. data/features/step_definitions/message_consumers_steps.rb +5 -0
  24. data/features/step_definitions/middleware_steps.rb +10 -0
  25. data/features/step_definitions/steps.rb +10 -2
  26. data/features/support/env.rb +4 -3
  27. data/features/support/firewall_helper.rb +1 -1
  28. data/features/support/message_table_matcher.rb +3 -2
  29. data/features/support/no_error_matcher.rb +2 -2
  30. data/features/support/test_runner.rb +11 -57
  31. data/features/support/transforms.rb +12 -10
  32. data/lib/message_driver.rb +3 -1
  33. data/lib/message_driver/adapters/base.rb +11 -11
  34. data/lib/message_driver/adapters/bunny_adapter.rb +189 -132
  35. data/lib/message_driver/adapters/in_memory_adapter.rb +51 -34
  36. data/lib/message_driver/adapters/stomp_adapter.rb +22 -23
  37. data/lib/message_driver/broker.rb +21 -16
  38. data/lib/message_driver/client.rb +15 -16
  39. data/lib/message_driver/destination.rb +26 -8
  40. data/lib/message_driver/message.rb +5 -4
  41. data/lib/message_driver/middleware.rb +8 -0
  42. data/lib/message_driver/middleware/base.rb +19 -0
  43. data/lib/message_driver/middleware/block_middleware.rb +33 -0
  44. data/lib/message_driver/middleware/middleware_stack.rb +61 -0
  45. data/lib/message_driver/subscription.rb +2 -2
  46. data/lib/message_driver/version.rb +1 -1
  47. data/message-driver.gemspec +3 -4
  48. data/spec/integration/bunny/amqp_integration_spec.rb +21 -82
  49. data/spec/integration/bunny/bunny_adapter_spec.rb +288 -268
  50. data/spec/integration/in_memory/in_memory_adapter_spec.rb +93 -90
  51. data/spec/integration/stomp/stomp_adapter_spec.rb +126 -93
  52. data/spec/spec_helper.rb +11 -9
  53. data/spec/support/shared/adapter_examples.rb +1 -1
  54. data/spec/support/shared/client_ack_examples.rb +4 -4
  55. data/spec/support/shared/context_examples.rb +6 -4
  56. data/spec/support/shared/destination_examples.rb +54 -14
  57. data/spec/support/shared/subscription_examples.rb +33 -26
  58. data/spec/support/shared/transaction_examples.rb +12 -12
  59. data/spec/support/utils.rb +1 -1
  60. data/spec/units/message_driver/adapters/base_spec.rb +42 -40
  61. data/spec/units/message_driver/broker_spec.rb +38 -38
  62. data/spec/units/message_driver/client_spec.rb +87 -87
  63. data/spec/units/message_driver/destination_spec.rb +16 -11
  64. data/spec/units/message_driver/message_spec.rb +96 -70
  65. data/spec/units/message_driver/middleware/base_spec.rb +30 -0
  66. data/spec/units/message_driver/middleware/block_middleware_spec.rb +82 -0
  67. data/spec/units/message_driver/middleware/middleware_stack_spec.rb +165 -0
  68. data/spec/units/message_driver/subscription_spec.rb +18 -16
  69. data/test_lib/broker_config.rb +21 -5
  70. data/test_lib/coverage.rb +11 -0
  71. data/test_lib/provider/base.rb +59 -0
  72. data/test_lib/provider/in_memory.rb +6 -0
  73. data/test_lib/provider/rabbitmq.rb +67 -0
  74. metadata +46 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38055d94b5d7646e9e1501075908bfc77a7432c5
4
- data.tar.gz: 68779796fd11f2f43b0cf563402d871a2e1fba2f
3
+ metadata.gz: 9fc4a4fb8a79dc70d8279847782608173d74bf1a
4
+ data.tar.gz: 95da288e0058edef7f3e913c9682025c4d0a6f97
5
5
  SHA512:
6
- metadata.gz: 607bb4df0b16a2858481caa86a76202a36a3736322c118ea54eb4107ca7b42556eadc921ff2b3216b39eff9f23088c8d59da7402d30c36569f83aff86f024621
7
- data.tar.gz: b16ace077a6b7b5b1d8094a1d4599a939d017aee51d00854145f1384eee8ab37abeaa82cdbd7047f433027ed51aab787c4879d0b2441fbe66b6ba0cffde4420b
6
+ metadata.gz: b487446f111ad51750587792819f8451c43c1da0154194c02710f933374a75618cf7147ef5c2cfa9b5c946d347e3500bf8a15a9779c48b9ec62feb8660511655
7
+ data.tar.gz: 6a2d604351dc987a08cd0c4548887233a8c31c04ed5aecc289ba647e1ce59b86cd8b5e2b59eb3ba12c06a4dfcafe67b6f21a1736785850b86f9ed6c7c694b56d
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+
data/.rubocop.yml CHANGED
@@ -6,13 +6,37 @@ AllCops:
6
6
  - '**/Gemfile'
7
7
  - 'Guardfile'
8
8
  - 'Rakefile'
9
+ Exclude:
10
+ - 'lib/vendor/**/*.rb'
11
+ - 'vendor/**/*'
12
+
13
+ Metrics/BlockNesting:
14
+ Max: 4
15
+
16
+ Metrics/LineLength:
17
+ AllowURI: true
18
+ Max: 120
19
+ Include:
20
+ - 'lib/**/*.rb'
9
21
 
10
22
  Style/AccessorMethodName:
11
23
  Enabled: false
12
24
 
13
- Style/BlockNesting:
14
- Max: 4
25
+ Style/Encoding:
26
+ Enabled: false
15
27
 
16
28
  Style/FileName:
17
29
  Exclude:
18
30
  - 'lib/message-driver.rb'
31
+
32
+ Style/NumericLiterals:
33
+ Enabled: false
34
+
35
+ Style/RegexpLiteral:
36
+ Exclude:
37
+ - 'Guardfile'
38
+
39
+ Style/TrivialAccessors:
40
+ ExactNameMatch: true
41
+ AllowPredicates: true
42
+ AllowDSLWriters: true
data/.rubocop_todo.yml CHANGED
@@ -1,88 +1,43 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-06-25 16:30:49 -0500 using RuboCop version 0.24.0.
2
+ # on 2014-09-15 17:44:35 -0500 using RuboCop version 0.26.0.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offense count: 84
9
- # Cop supports --auto-correct.
10
- Style/Blocks:
11
- Enabled: false
12
-
13
8
  # Offense count: 2
14
- # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
15
- Style/CaseIndentation:
9
+ # Configuration parameters: CountComments.
10
+ Metrics/ClassLength:
16
11
  Enabled: false
17
12
 
18
- # Offense count: 7
19
- # Configuration parameters: EnforcedStyle, SupportedStyles.
20
- Style/ClassAndModuleChildren:
13
+ # Offense count: 4
14
+ Metrics/CyclomaticComplexity:
21
15
  Enabled: false
22
16
 
23
- # Offense count: 2
17
+ # Offense count: 15
24
18
  # Configuration parameters: CountComments.
25
- Style/ClassLength:
19
+ Metrics/MethodLength:
26
20
  Enabled: false
27
21
 
28
- # Offense count: 4
29
- Style/CyclomaticComplexity:
30
- Max: 12
22
+ # Offense count: 3
23
+ Metrics/PerceivedComplexity:
24
+ Enabled: false
31
25
 
32
- # Offense count: 50
26
+ # Offense count: 63
33
27
  Style/Documentation:
34
28
  Enabled: false
35
29
 
36
- # Offense count: 8
30
+ # Offense count: 9
37
31
  # Configuration parameters: MinBodyLength.
38
32
  Style/GuardClause:
39
33
  Enabled: false
40
34
 
41
- # Offense count: 4
42
- # Configuration parameters: MaxLineLength.
43
- Style/IfUnlessModifier:
44
- Enabled: false
45
-
46
- # Offense count: 9
47
- Style/Lambda:
48
- Enabled: false
49
-
50
- # Offense count: 6
51
- # Cop supports --auto-correct.
52
- Style/LeadingCommentSpace:
53
- Enabled: false
54
-
55
- # Offense count: 165
56
- # Configuration parameters: AllowURI.
57
- Style/LineLength:
58
- Max: 181
59
-
60
- # Offense count: 14
61
- # Configuration parameters: CountComments.
62
- Style/MethodLength:
63
- Max: 29
64
-
65
35
  # Offense count: 2
66
36
  Style/ModuleFunction:
67
37
  Enabled: false
68
38
 
69
- # Offense count: 2
70
- Style/MultilineBlockChain:
71
- Enabled: false
72
-
73
39
  # Offense count: 1
74
- # Configuration parameters: EnforcedStyle, SupportedStyles.
75
- Style/Next:
76
- Enabled: false
77
-
78
- # Offense count: 2
79
- # Cop supports --auto-correct.
80
- Style/NumericLiterals:
81
- MinDigits: 6
82
-
83
- # Offense count: 1
84
- # Configuration parameters: NamePrefixBlacklist.
85
- Style/PredicateName:
40
+ Style/MultilineBlockChain:
86
41
  Enabled: false
87
42
 
88
43
  # Offense count: 1
@@ -90,71 +45,8 @@ Style/PredicateName:
90
45
  Style/RaiseArgs:
91
46
  Enabled: false
92
47
 
93
- # Offense count: 7
94
- # Cop supports --auto-correct.
95
- Style/RedundantBegin:
96
- Enabled: false
97
-
98
- # Offense count: 4
99
- # Cop supports --auto-correct.
100
- Style/RedundantSelf:
101
- Enabled: false
102
-
103
- # Offense count: 2
104
- Style/RegexpLiteral:
105
- MaxSlashes: 0
106
-
107
- # Offense count: 1
108
- Style/SelfAssignment:
109
- Enabled: false
110
-
111
- # Offense count: 41
112
- # Cop supports --auto-correct.
113
- # Configuration parameters: EnforcedStyle, SupportedStyles.
114
- Style/SignalException:
115
- Enabled: false
116
-
117
- # Offense count: 1
118
- # Cop supports --auto-correct.
119
- Style/SpaceAfterComma:
120
- Enabled: false
121
-
122
- # Offense count: 61
123
- # Cop supports --auto-correct.
124
- # Configuration parameters: EnforcedStyle, SupportedStyles.
125
- Style/SpaceAroundEqualsInParameterDefault:
126
- Enabled: false
127
-
128
- # Offense count: 9
129
- # Cop supports --auto-correct.
130
- Style/SpaceAroundOperators:
131
- Enabled: false
132
-
133
- # Offense count: 11
134
- # Cop supports --auto-correct.
135
- # Configuration parameters: EnforcedStyle, SupportedStyles.
136
- Style/SpaceBeforeBlockBraces:
137
- Enabled: false
138
-
139
- # Offense count: 22
140
- # Cop supports --auto-correct.
141
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
142
- Style/SpaceInsideBlockBraces:
143
- Enabled: false
144
-
145
- # Offense count: 101
146
- # Cop supports --auto-correct.
147
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
148
- Style/SpaceInsideHashLiteralBraces:
149
- Enabled: false
150
-
151
48
  # Offense count: 3
152
49
  # Cop supports --auto-correct.
153
- Style/SpecialGlobalVars:
154
- Enabled: false
155
-
156
- # Offense count: 7
157
- # Cop supports --auto-correct.
158
- # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
159
- Style/TrivialAccessors:
50
+ # Configuration parameters: IgnoredMethods.
51
+ Style/SymbolProc:
160
52
  Enabled: false
data/.travis.yml CHANGED
@@ -15,9 +15,10 @@ rvm:
15
15
  - rbx-2
16
16
  env:
17
17
  - ADAPTER=in_memory
18
- - ADAPTER=stomp
19
18
  - ADAPTER=bunny:1.2.2
20
19
  - ADAPTER=bunny:1.3.1
20
+ - ADAPTER=bunny:1.4.0
21
+ - ADAPTER=stomp
21
22
  matrix:
22
23
  allow_failures:
23
24
  - rvm: jruby-19mode
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - 2014-09-17
4
+
5
+ * add support for checking consumer counts on a queue in bunny and in_memory adapters
6
+ * in_memory adapter now supports multiple subscribers per queue, and does a round-robin
7
+ through them when sending messages to consumers
8
+ * upgrade to rspec 3
9
+ * Middleware can now be used to automatically pre/post-process messages as they are published to
10
+ or consumed from a destination
11
+
3
12
  ## 0.4.0 - 2014-07-03
4
13
 
5
14
  * require bunny 1.2.2 or later
@@ -10,7 +19,7 @@
10
19
  * Support for handling multiple broker connections
11
20
  * require bunny 1.1.3 or later
12
21
  * make bunny connections as lazily initialized as possible
13
- * bunny transaction start lazily
22
+ * bunny transactions start lazily
14
23
 
15
24
  ## 0.2.2 - 2014-02-21
16
25
 
data/Gemfile CHANGED
@@ -7,14 +7,17 @@ platform :rbx do
7
7
  gem 'rubysl'
8
8
  end
9
9
 
10
+ gem 'rubocop', platform: [:ruby_20, :ruby_21]
11
+
10
12
  group :tools do
11
- gem 'guard'
12
- gem 'guard-bundler'
13
- gem 'guard-rspec'
14
- gem 'guard-cucumber'
15
- gem 'guard-rubocop'
13
+ gem 'guard', platform: [:mri_20, :mri_21]
14
+ gem 'guard-bundler', platform: [:mri_20, :mri_21]
15
+ gem 'guard-rspec', platform: [:mri_20, :mri_21]
16
+ gem 'guard-cucumber', platform: [:mri_20, :mri_21]
17
+ gem 'guard-rubocop', platform: [:mri_20, :mri_21]
16
18
  gem 'pry'
17
19
  gem 'pry-byebug', platform: [:mri_20, :mri_21]
20
+ gem 'pry-stack_explorer', platform: [:ruby_20, :ruby_21]
18
21
  group :darwin do
19
22
  gem 'ruby_gntp'
20
23
  gem 'rb-fsevent'
@@ -24,12 +27,13 @@ group :tools do
24
27
  gem 'yard'
25
28
  gem 'redcarpet'
26
29
  gem 'launchy'
27
- end if RUBY_VERSION >= '1.9.3'
30
+ end
28
31
 
29
32
  require File.expand_path('../test_lib/broker_config', __FILE__)
30
33
 
31
34
  adapter = BrokerConfig.current_adapter.to_s
32
35
  version = BrokerConfig.adapter_version
36
+ provider = BrokerConfig.provider
33
37
 
34
38
  case adapter
35
39
  when 'in_memory'
@@ -42,4 +46,9 @@ else
42
46
  end
43
47
  end
44
48
 
49
+ case provider
50
+ when :rabbitmq
51
+ gem 'rabbitmq_http_api_client', '> 1.3.0', github: 'soupmatt/rabbitmq_http_api_client', branch: :master
52
+ end
53
+
45
54
  gem 'coveralls', require: false
data/Rakefile CHANGED
@@ -8,6 +8,14 @@ require 'cucumber/rake/task'
8
8
 
9
9
  require 'coveralls/rake/task'
10
10
 
11
+ begin
12
+ require 'rubocop/rake_task'
13
+ RuboCop::RakeTask.new
14
+ rescue LoadError
15
+ puts 'rubocop not present'
16
+ task 'rubocop'
17
+ end
18
+
11
19
  namespace :spec do
12
20
  desc 'Run unit specs'
13
21
  RSpec::Core::RakeTask.new(:units) do |t|
@@ -21,22 +29,25 @@ namespace :spec do
21
29
  end
22
30
 
23
31
  cucumber_opts = "--format progress --tag @all_adapters,@#{BrokerConfig.current_adapter} --tag ~@wip"
24
- cucumber_opts += ' --tag ~@no_ci' if ENV['CI']=='true' && ENV['ADAPTER'] && ENV['ADAPTER'].start_with?('bunny')
32
+ cucumber_opts += ' --tag ~@no_ci' if ENV['CI'] == 'true' && ENV['ADAPTER'] && ENV['ADAPTER'].start_with?('bunny')
25
33
  Cucumber::Rake::Task.new(:features) do |t|
26
34
  t.cucumber_opts = cucumber_opts
27
35
  end
28
36
 
29
- desc 'run all the specs'
30
37
  task all: [:units, :integrations, :features]
38
+ end
31
39
 
32
- desc 'run all the specs for each adapter'
33
- task :all_adapters do
34
- current_adapter = BrokerConfig.current_adapter
35
- BrokerConfig.all_adapters.each do |adapter|
36
- set_adapter_under_test(adapter)
37
- system('rake spec:all')
38
- end
39
- set_adapter_under_test(current_adapter)
40
+ desc 'run all the specs'
41
+ task spec: ['rabbitmq:reset_vhost', 'spec:all']
42
+
43
+ namespace :rabbitmq do
44
+ desc 'Reset rabbit vhost'
45
+ task :reset_vhost do
46
+ rabbitmqctl = ENV['CI'] ? 'sudo rabbitmqctl' : 'rabbitmqctl'
47
+ vhost = ENV['VHOST'] || 'message-driver-test'
48
+ system "#{rabbitmqctl} delete_vhost #{vhost}"
49
+ system "#{rabbitmqctl} add_vhost #{vhost}"
50
+ system "#{rabbitmqctl} set_permissions -p #{vhost} guest \".*\" \".*\" \".*\""
40
51
  end
41
52
  end
42
53
 
@@ -46,7 +57,7 @@ end
46
57
 
47
58
  Coveralls::RakeTask.new
48
59
  desc 'run with code coverage'
49
- task ci: ['spec:all', 'coveralls:push']
60
+ task ci: ['spec', 'rubocop', 'coveralls:push']
50
61
 
51
62
  namespace :undertest do
52
63
  BrokerConfig.all_adapters.each do |adapter|
@@ -57,4 +68,4 @@ namespace :undertest do
57
68
  end
58
69
  end
59
70
 
60
- task default: ['spec:all']
71
+ task default: [:spec, :rubocop]
data/ci/reset_vhost CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/bin/bash
2
2
 
3
- rabbitmqctl delete_vhost message-driver-test
4
- rabbitmqctl add_vhost message-driver-test
5
- rabbitmqctl set_permissions -p message-driver-test guest ".*" ".*" ".*"
3
+ #vhost="message-driver-test-$ADAPTER-$(rbenv version-name)"
4
+ vhost="message-driver-test"
5
+
6
+ echo $vhost
7
+
8
+ rabbitmqctl delete_vhost $vhost
9
+ rabbitmqctl add_vhost $vhost
10
+ rabbitmqctl set_permissions -p $vhost guest ".*" ".*" ".*"
data/ci/travis_setup CHANGED
@@ -1,8 +1,5 @@
1
1
  #!/bin/bash
2
2
 
3
- sudo rabbitmqctl add_vhost message-driver-test
4
- sudo rabbitmqctl set_permissions -p message-driver-test guest ".*" ".*" ".*"
5
-
6
3
  if [ "$ADAPTER" = "stomp" ]; then
7
4
  sudo rabbitmq-plugins enable rabbitmq_stomp
8
5
  sudo service rabbitmq-server restart
data/features/.nav CHANGED
@@ -13,7 +13,12 @@
13
13
  - transactional_ack_consumers.feature
14
14
  - prefetch_size.feature
15
15
  - subscribe_with_a_block.feature
16
- - amqp_specific_features (AMQP-Specific Features):
16
+ - middleware
17
+ - middleware_basics.feature
18
+ - middleware_ordering.feature
19
+ - middleware_parameters.feature
20
+ - middleware_with_blocks.feature
21
+ - amqp_specific_features (AMQP-Specific Features)
17
22
  - declaring_amqp_destinations.feature
18
23
  - binding_amqp_destinations.feature
19
24
  - server_named_desitnations.feature
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - 2014-09-17
4
+
5
+ * add support for checking consumer counts on a queue in bunny and in_memory adapters
6
+ * in_memory adapter now supports multiple subscribers per queue, and does a round-robin
7
+ through them when sending messages to consumers
8
+ * upgrade to rspec 3
9
+ * Middleware can now be used to automatically pre/post-process messages as they are published to
10
+ or consumed from a destination
11
+
3
12
  ## 0.4.0 - 2014-07-03
4
13
 
5
14
  * require bunny 1.2.2 or later
@@ -10,7 +19,7 @@
10
19
  * Support for handling multiple broker connections
11
20
  * require bunny 1.1.3 or later
12
21
  * make bunny connections as lazily initialized as possible
13
- * bunny transaction start lazily
22
+ * bunny transactions start lazily
14
23
 
15
24
  ## 0.2.2 - 2014-02-21
16
25