action_subscriber 1.0.3

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 +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +20 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +122 -0
  8. data/Rakefile +8 -0
  9. data/action_subscriber.gemspec +38 -0
  10. data/examples/at_least_once.rb +17 -0
  11. data/examples/at_most_once.rb +15 -0
  12. data/examples/basic_subscriber.rb +30 -0
  13. data/examples/message_acknowledgement.rb +19 -0
  14. data/lib/action_subscriber.rb +93 -0
  15. data/lib/action_subscriber/base.rb +83 -0
  16. data/lib/action_subscriber/bunny/subscriber.rb +57 -0
  17. data/lib/action_subscriber/configuration.rb +68 -0
  18. data/lib/action_subscriber/default_routing.rb +26 -0
  19. data/lib/action_subscriber/dsl.rb +83 -0
  20. data/lib/action_subscriber/march_hare/subscriber.rb +60 -0
  21. data/lib/action_subscriber/middleware.rb +18 -0
  22. data/lib/action_subscriber/middleware/active_record/connection_management.rb +17 -0
  23. data/lib/action_subscriber/middleware/active_record/query_cache.rb +29 -0
  24. data/lib/action_subscriber/middleware/decoder.rb +33 -0
  25. data/lib/action_subscriber/middleware/env.rb +65 -0
  26. data/lib/action_subscriber/middleware/error_handler.rb +16 -0
  27. data/lib/action_subscriber/middleware/router.rb +17 -0
  28. data/lib/action_subscriber/middleware/runner.rb +16 -0
  29. data/lib/action_subscriber/rabbit_connection.rb +40 -0
  30. data/lib/action_subscriber/railtie.rb +13 -0
  31. data/lib/action_subscriber/rspec.rb +91 -0
  32. data/lib/action_subscriber/subscribable.rb +118 -0
  33. data/lib/action_subscriber/threadpool.rb +29 -0
  34. data/lib/action_subscriber/version.rb +3 -0
  35. data/spec/integration/basic_subscriber_spec.rb +42 -0
  36. data/spec/lib/action_subscriber/base_spec.rb +18 -0
  37. data/spec/lib/action_subscriber/configuration_spec.rb +32 -0
  38. data/spec/lib/action_subscriber/dsl_spec.rb +143 -0
  39. data/spec/lib/action_subscriber/middleware/active_record/connection_management_spec.rb +17 -0
  40. data/spec/lib/action_subscriber/middleware/active_record/query_cache_spec.rb +49 -0
  41. data/spec/lib/action_subscriber/middleware/decoder_spec.rb +31 -0
  42. data/spec/lib/action_subscriber/middleware/env_spec.rb +60 -0
  43. data/spec/lib/action_subscriber/middleware/error_handler_spec.rb +35 -0
  44. data/spec/lib/action_subscriber/middleware/router_spec.rb +24 -0
  45. data/spec/lib/action_subscriber/middleware/runner_spec.rb +6 -0
  46. data/spec/lib/action_subscriber/subscribable_spec.rb +128 -0
  47. data/spec/lib/action_subscriber/threadpool_spec.rb +35 -0
  48. data/spec/spec_helper.rb +26 -0
  49. data/spec/support/user_subscriber.rb +6 -0
  50. metadata +257 -0
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::ActionSubscriber::Threadpool do
4
+ describe "busy?" do
5
+ context "when the workers are busy" do
6
+ it "returns true" do
7
+ allow(::ActionSubscriber::Threadpool.pool).to receive(:busy_size).and_return(8)
8
+ expect(::ActionSubscriber::Threadpool.busy?).to eq(true)
9
+ end
10
+ end
11
+
12
+ context "when there are idle workers" do
13
+ it "returns false" do
14
+ allow(::ActionSubscriber::Threadpool.pool).to receive(:busy_size).and_return(1)
15
+ expect(::ActionSubscriber::Threadpool.busy?).to eq(false)
16
+ end
17
+ end
18
+ end
19
+
20
+ describe "ready?" do
21
+ context "when the pool is busy" do
22
+ it "returns false" do
23
+ allow(::ActionSubscriber::Threadpool).to receive(:busy?).and_return true
24
+ expect(::ActionSubscriber::Threadpool.ready?).to eq(false)
25
+ end
26
+ end
27
+
28
+ context "when the pool is not busy" do
29
+ it "returns true" do
30
+ allow(::ActionSubscriber::Threadpool).to receive(:busy?).and_return false
31
+ expect(::ActionSubscriber::Threadpool.ready?).to eq(true)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ require 'simplecov'
5
+ ENV['APP_NAME'] = 'Alice'
6
+
7
+
8
+ SimpleCov.start do
9
+ add_filter 'spec'
10
+ end
11
+
12
+ Bundler.require(:default, :development, :test)
13
+
14
+ require 'action_subscriber'
15
+ require 'active_record'
16
+
17
+ # Require spec support files
18
+ require 'support/user_subscriber'
19
+
20
+ require 'action_subscriber/rspec'
21
+
22
+ RSpec.configure do |config|
23
+ config.mock_with :rspec do |mocks|
24
+ mocks.verify_partial_doubles = true
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ class UserSubscriber < ActionSubscriber::Base
2
+ exchange :events
3
+
4
+ def created
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,257 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: action_subscriber
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Brian Stien
8
+ - Adam Hutchison
9
+ - Brandon Dewitt
10
+ - Devin Christensen
11
+ - Michael Ries
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2014-11-11 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: activesupport
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: '3.2'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '3.2'
31
+ - !ruby/object:Gem::Dependency
32
+ name: bunny
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 1.5.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.5.0
45
+ - !ruby/object:Gem::Dependency
46
+ name: lifeguard
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ type: :runtime
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ - !ruby/object:Gem::Dependency
60
+ name: middleware
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: activerecord
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '3.2'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '3.2'
87
+ - !ruby/object:Gem::Dependency
88
+ name: bundler
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '1.6'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '1.6'
101
+ - !ruby/object:Gem::Dependency
102
+ name: pry-nav
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: rspec
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '3.0'
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: '3.0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rake
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: simplecov
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ description: ActionSubscriber is a DSL that allows a rails app to consume messages
158
+ from a RabbitMQ broker.
159
+ email:
160
+ - brianastien@gmail.com
161
+ - liveh2o@gmail.com
162
+ - brandonsdewitt@gmail.com
163
+ - quixoten@gmail.com
164
+ - michael@riesd.com
165
+ executables: []
166
+ extensions: []
167
+ extra_rdoc_files: []
168
+ files:
169
+ - ".gitignore"
170
+ - ".rspec"
171
+ - Gemfile
172
+ - LICENSE
173
+ - LICENSE.txt
174
+ - README.md
175
+ - Rakefile
176
+ - action_subscriber.gemspec
177
+ - examples/at_least_once.rb
178
+ - examples/at_most_once.rb
179
+ - examples/basic_subscriber.rb
180
+ - examples/message_acknowledgement.rb
181
+ - lib/action_subscriber.rb
182
+ - lib/action_subscriber/base.rb
183
+ - lib/action_subscriber/bunny/subscriber.rb
184
+ - lib/action_subscriber/configuration.rb
185
+ - lib/action_subscriber/default_routing.rb
186
+ - lib/action_subscriber/dsl.rb
187
+ - lib/action_subscriber/march_hare/subscriber.rb
188
+ - lib/action_subscriber/middleware.rb
189
+ - lib/action_subscriber/middleware/active_record/connection_management.rb
190
+ - lib/action_subscriber/middleware/active_record/query_cache.rb
191
+ - lib/action_subscriber/middleware/decoder.rb
192
+ - lib/action_subscriber/middleware/env.rb
193
+ - lib/action_subscriber/middleware/error_handler.rb
194
+ - lib/action_subscriber/middleware/router.rb
195
+ - lib/action_subscriber/middleware/runner.rb
196
+ - lib/action_subscriber/rabbit_connection.rb
197
+ - lib/action_subscriber/railtie.rb
198
+ - lib/action_subscriber/rspec.rb
199
+ - lib/action_subscriber/subscribable.rb
200
+ - lib/action_subscriber/threadpool.rb
201
+ - lib/action_subscriber/version.rb
202
+ - spec/integration/basic_subscriber_spec.rb
203
+ - spec/lib/action_subscriber/base_spec.rb
204
+ - spec/lib/action_subscriber/configuration_spec.rb
205
+ - spec/lib/action_subscriber/dsl_spec.rb
206
+ - spec/lib/action_subscriber/middleware/active_record/connection_management_spec.rb
207
+ - spec/lib/action_subscriber/middleware/active_record/query_cache_spec.rb
208
+ - spec/lib/action_subscriber/middleware/decoder_spec.rb
209
+ - spec/lib/action_subscriber/middleware/env_spec.rb
210
+ - spec/lib/action_subscriber/middleware/error_handler_spec.rb
211
+ - spec/lib/action_subscriber/middleware/router_spec.rb
212
+ - spec/lib/action_subscriber/middleware/runner_spec.rb
213
+ - spec/lib/action_subscriber/subscribable_spec.rb
214
+ - spec/lib/action_subscriber/threadpool_spec.rb
215
+ - spec/spec_helper.rb
216
+ - spec/support/user_subscriber.rb
217
+ homepage: ''
218
+ licenses:
219
+ - MIT
220
+ metadata: {}
221
+ post_install_message:
222
+ rdoc_options: []
223
+ require_paths:
224
+ - lib
225
+ required_ruby_version: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ required_rubygems_version: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ version: '0'
235
+ requirements: []
236
+ rubyforge_project:
237
+ rubygems_version: 2.4.2
238
+ signing_key:
239
+ specification_version: 4
240
+ summary: ActionSubscriber is a DSL that allows a rails app to consume messages from
241
+ a RabbitMQ broker.
242
+ test_files:
243
+ - spec/integration/basic_subscriber_spec.rb
244
+ - spec/lib/action_subscriber/base_spec.rb
245
+ - spec/lib/action_subscriber/configuration_spec.rb
246
+ - spec/lib/action_subscriber/dsl_spec.rb
247
+ - spec/lib/action_subscriber/middleware/active_record/connection_management_spec.rb
248
+ - spec/lib/action_subscriber/middleware/active_record/query_cache_spec.rb
249
+ - spec/lib/action_subscriber/middleware/decoder_spec.rb
250
+ - spec/lib/action_subscriber/middleware/env_spec.rb
251
+ - spec/lib/action_subscriber/middleware/error_handler_spec.rb
252
+ - spec/lib/action_subscriber/middleware/router_spec.rb
253
+ - spec/lib/action_subscriber/middleware/runner_spec.rb
254
+ - spec/lib/action_subscriber/subscribable_spec.rb
255
+ - spec/lib/action_subscriber/threadpool_spec.rb
256
+ - spec/spec_helper.rb
257
+ - spec/support/user_subscriber.rb