action_subscriber 3.0.2-java → 4.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,25 +11,12 @@ describe "A Basic Subscriber", :integration => true do
11
11
  end
12
12
  end
13
13
 
14
- context "ActionSubscriber.auto_pop!" do
15
- it "routes messages to the right place" do
16
- ::ActivePublisher.publish("basic_push.booked", "Ohai Booked", "events")
14
+ it "routes messages to the right place" do
15
+ ::ActionSubscriber.start_subscribers!
16
+ ::ActivePublisher.publish("basic_push.booked", "Ohai Booked", "events")
17
17
 
18
- verify_expectation_within(2.0) do
19
- ::ActionSubscriber.auto_pop!
20
- expect($messages).to eq(Set.new(["Ohai Booked"]))
21
- end
22
- end
23
- end
24
-
25
- context "ActionSubscriber.auto_subscribe!" do
26
- it "routes messages to the right place" do
27
- ::ActionSubscriber.auto_subscribe!
28
- ::ActivePublisher.publish("basic_push.booked", "Ohai Booked", "events")
29
-
30
- verify_expectation_within(2.0) do
31
- expect($messages).to eq(Set.new(["Ohai Booked"]))
32
- end
18
+ verify_expectation_within(2.0) do
19
+ expect($messages).to eq(Set.new(["Ohai Booked"]))
33
20
  end
34
21
  end
35
22
  end
@@ -14,7 +14,7 @@ describe "A subscriber with a custom action", :integration => true do
14
14
  end
15
15
 
16
16
  it "routes the message to the selected action" do
17
- ::ActionSubscriber.auto_subscribe!
17
+ ::ActionSubscriber.start_subscribers!
18
18
  ::ActivePublisher.publish("react.javascript_framework", "Another?!?!", "events")
19
19
 
20
20
  verify_expectation_within(2.0) do
@@ -13,17 +13,9 @@ describe "Custom Headers Are Published and Received", :integration => true do
13
13
  end
14
14
  end
15
15
  let(:headers) { { "Custom" => "content/header" } }
16
-
17
- it "works for auto_pop!" do
18
- ::ActivePublisher.publish("pikitis.prank.pulled", "Yo Knope!", "events", :headers => headers)
19
- verify_expectation_within(2.0) do
20
- ::ActionSubscriber.auto_pop!
21
- expect($messages).to eq(Set.new([headers]))
22
- end
23
- end
24
-
25
- it "works for auto_subscriber!" do
26
- ::ActionSubscriber.auto_subscribe!
16
+
17
+ it "passes custom headers through" do
18
+ ::ActionSubscriber.start_subscribers!
27
19
  ::ActivePublisher.publish("pikitis.prank.pulled", "Yo Knope!", "events", :headers => headers)
28
20
  verify_expectation_within(2.0) do
29
21
  expect($messages).to eq(Set.new([headers]))
@@ -19,7 +19,7 @@ describe "Payload Decoding", :integration => true do
19
19
  let(:json_string) { '{"foo": "bar"}' }
20
20
 
21
21
  it "decodes json by default" do
22
- ::ActionSubscriber.auto_subscribe!
22
+ ::ActionSubscriber.start_subscribers!
23
23
  ::ActivePublisher.publish("twitter.tweet", json_string, "events", :content_type => "application/json")
24
24
 
25
25
  verify_expectation_within(2.0) do
@@ -37,7 +37,7 @@ describe "Payload Decoding", :integration => true do
37
37
  after { ::ActionSubscriber.config.decoder.delete(content_type) }
38
38
 
39
39
  it "it decodes the payload using the custom decoder" do
40
- ::ActionSubscriber.auto_subscribe!
40
+ ::ActionSubscriber.start_subscribers!
41
41
  ::ActivePublisher.publish("twitter.tweet", json_string, "events", :content_type => content_type)
42
42
 
43
43
  verify_expectation_within(2.0) do
@@ -21,7 +21,7 @@ describe "Manual Message Acknowledgment", :integration => true do
21
21
  let(:subscriber) { BaconSubscriber }
22
22
 
23
23
  it "retries rejected messages and stops retrying acknowledged messages" do
24
- ::ActionSubscriber.auto_subscribe!
24
+ ::ActionSubscriber.start_subscribers!
25
25
  ::ActivePublisher.publish("bacon.served", "BACON!", "events")
26
26
 
27
27
  verify_expectation_within(2.0) do
@@ -24,7 +24,7 @@ describe "Separate connections to get multiple threadpools", :integration => tru
24
24
  end
25
25
 
26
26
  it "spreads the load across multiple threadpools and consumer" do
27
- ::ActionSubscriber.auto_subscribe!
27
+ ::ActionSubscriber.start_subscribers!
28
28
  1.upto(10).each do |i|
29
29
  ::ActivePublisher.publish("multiple_connections.burp", "belch#{i}", "events")
30
30
  end
@@ -4,14 +4,11 @@ describe ::ActionSubscriber::Configuration do
4
4
  specify { expect(subject.default_exchange).to eq("events") }
5
5
  specify { expect(subject.heartbeat).to eq(5) }
6
6
  specify { expect(subject.host).to eq("localhost") }
7
- specify { expect(subject.mode).to eq('subscribe') }
8
- specify { expect(subject.pop_interval).to eq(100) }
9
7
  specify { expect(subject.port).to eq(5672) }
10
8
  specify { expect(subject.prefetch).to eq(2) }
11
9
  specify { expect(subject.seconds_to_wait_for_graceful_shutdown).to eq(30) }
12
10
  specify { expect(subject.threadpool_size).to eq(8) }
13
11
  specify { expect(subject.timeout).to eq(1) }
14
- specify { expect(subject.times_to_pop).to eq(8) }
15
12
  end
16
13
 
17
14
  describe "add_decoder" do
@@ -28,12 +28,12 @@ RSpec.configure do |config|
28
28
  ::ActionSubscriber.setup_subscriptions!
29
29
  end
30
30
  config.after(:each, :integration => true) do
31
- ::ActionSubscriber.stop_subscribers!
31
+ ::ActionSubscriber.stop_subscribers!(0.1)
32
32
  ::ActionSubscriber.instance_variable_set("@route_set", nil)
33
33
  ::ActionSubscriber.instance_variable_set("@route_set_block", nil)
34
34
  end
35
35
  config.after(:suite) do
36
- ::ActionSubscriber.stop_subscribers!
36
+ ::ActionSubscriber.stop_subscribers!(0.1)
37
37
  ::ActionSubscriber::RabbitConnection.subscriber_disconnect!
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_subscriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 4.0.0
5
5
  platform: java
6
6
  authors:
7
7
  - Brian Stien
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-09-26 00:00:00.000000000 Z
15
+ date: 2016-09-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  requirement: !ruby/object:Gem::Requirement
@@ -42,20 +42,6 @@ dependencies:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: 2.7.0
45
- - !ruby/object:Gem::Dependency
46
- requirement: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 0.0.9
51
- name: lifeguard
52
- prerelease: false
53
- type: :runtime
54
- version_requirements: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: 0.0.9
59
45
  - !ruby/object:Gem::Dependency
60
46
  requirement: !ruby/object:Gem::Requirement
61
47
  requirements:
@@ -234,7 +220,6 @@ files:
234
220
  - lib/action_subscriber/router.rb
235
221
  - lib/action_subscriber/rspec.rb
236
222
  - lib/action_subscriber/subscribable.rb
237
- - lib/action_subscriber/threadpool.rb
238
223
  - lib/action_subscriber/uri.rb
239
224
  - lib/action_subscriber/version.rb
240
225
  - routing.md
@@ -248,7 +233,6 @@ files:
248
233
  - spec/integration/decoding_payloads_spec.rb
249
234
  - spec/integration/manual_acknowledgement_spec.rb
250
235
  - spec/integration/multiple_connections_spec.rb
251
- - spec/integration/multiple_threadpools_spec.rb
252
236
  - spec/lib/action_subscriber/base_spec.rb
253
237
  - spec/lib/action_subscriber/configuration_spec.rb
254
238
  - spec/lib/action_subscriber/dsl_spec.rb
@@ -261,7 +245,6 @@ files:
261
245
  - spec/lib/action_subscriber/middleware/runner_spec.rb
262
246
  - spec/lib/action_subscriber/router_spec.rb
263
247
  - spec/lib/action_subscriber/subscribable_spec.rb
264
- - spec/lib/action_subscriber/threadpool_spec.rb
265
248
  - spec/spec_helper.rb
266
249
  - spec/support/user_subscriber.rb
267
250
  homepage: https://github.com/mxenabled/action_subscriber
@@ -284,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
267
  version: '0'
285
268
  requirements: []
286
269
  rubyforge_project:
287
- rubygems_version: 2.6.6
270
+ rubygems_version: 2.6.7
288
271
  signing_key:
289
272
  specification_version: 4
290
273
  summary: ActionSubscriber is a DSL that allows a rails app to consume messages from a RabbitMQ broker.
@@ -299,7 +282,6 @@ test_files:
299
282
  - spec/integration/decoding_payloads_spec.rb
300
283
  - spec/integration/manual_acknowledgement_spec.rb
301
284
  - spec/integration/multiple_connections_spec.rb
302
- - spec/integration/multiple_threadpools_spec.rb
303
285
  - spec/lib/action_subscriber/base_spec.rb
304
286
  - spec/lib/action_subscriber/configuration_spec.rb
305
287
  - spec/lib/action_subscriber/dsl_spec.rb
@@ -312,6 +294,5 @@ test_files:
312
294
  - spec/lib/action_subscriber/middleware/runner_spec.rb
313
295
  - spec/lib/action_subscriber/router_spec.rb
314
296
  - spec/lib/action_subscriber/subscribable_spec.rb
315
- - spec/lib/action_subscriber/threadpool_spec.rb
316
297
  - spec/spec_helper.rb
317
298
  - spec/support/user_subscriber.rb
@@ -1,62 +0,0 @@
1
- module ActionSubscriber
2
- class Threadpool
3
- ##
4
- # Class Methods
5
- #
6
- def self.busy?
7
- !ready?
8
- end
9
-
10
- def self.new_pool(name, pool_size = nil)
11
- fail ArgumentError, "#{name} already exists as a threadpool" if pools.key?(name)
12
- pool_size ||= ::ActionSubscriber.config.threadpool_size
13
- pools[name] = ::Lifeguard::InfiniteThreadpool.new(
14
- :name => name,
15
- :pool_size => pool_size
16
- )
17
- end
18
-
19
- def self.pool(which_pool = :default)
20
- pools[which_pool]
21
- end
22
-
23
- def self.pools
24
- @pools ||= {
25
- :default => ::Lifeguard::InfiniteThreadpool.new(
26
- :name => :default,
27
- :pool_size => ::ActionSubscriber.config.threadpool_size
28
- )
29
- }
30
- end
31
-
32
- def self.ready?
33
- pools.any? { |_pool_name, pool| !pool.busy? }
34
- end
35
-
36
- def self.ready_size
37
- pools.inject(0) do |total_ready, (_pool_name, pool)|
38
- total_ready + [0, pool.pool_size - pool.busy_size].max
39
- end
40
- end
41
-
42
- def self.wait_to_finish_with_timeout(timeout)
43
- wait_loops = 0
44
- loop do
45
- wait_loops = wait_loops + 1
46
- any_threadpools_busy = false
47
- pools.each do |name, pool|
48
- next if pool.busy_size <= 0
49
- puts " -- #{name} (remaining: #{pool.busy_size})"
50
- any_threadpools_busy = true
51
- end
52
- if !any_threadpools_busy
53
- puts " -- Lifeguard threadpools empty"
54
- break
55
- end
56
- break if wait_loops >= timeout
57
- Thread.pass
58
- sleep 1
59
- end
60
- end
61
- end
62
- end
@@ -1,29 +0,0 @@
1
- class DifferentThreadpoolsSubscriber < ActionSubscriber::Base
2
- def one
3
- $messages << payload
4
- end
5
-
6
- def two
7
- $messages << payload
8
- end
9
- end
10
-
11
- describe "Separate Threadpools for Different Message", :integration => true do
12
- let(:draw_routes) do
13
- low_priority_threadpool = ::ActionSubscriber::Threadpool.new_pool(:low_priority, 1)
14
- ::ActionSubscriber.draw_routes do
15
- route DifferentThreadpoolsSubscriber, :one
16
- route DifferentThreadpoolsSubscriber, :two, :threadpool => low_priority_threadpool
17
- end
18
- end
19
-
20
- it "processes messages in separate threadpools based on the routes" do
21
- ::ActivePublisher.publish("different_threadpools.one", "ONE", "events")
22
- ::ActivePublisher.publish("different_threadpools.two", "TWO", "events")
23
-
24
- verify_expectation_within(2.0) do
25
- ::ActionSubscriber.auto_pop!
26
- expect($messages).to eq(Set.new(["ONE","TWO"]))
27
- end
28
- end
29
- end
@@ -1,47 +0,0 @@
1
- describe ::ActionSubscriber::Threadpool do
2
- describe "busy?" do
3
- context "when the pool is busy" do
4
- it "returns true" do
5
- allow(::ActionSubscriber::Threadpool).to receive(:ready?).and_return(false)
6
- expect(::ActionSubscriber::Threadpool).to be_busy
7
- end
8
- end
9
-
10
- context "when the pool is not busy" do
11
- it "returns false" do
12
- allow(::ActionSubscriber::Threadpool).to receive(:ready?).and_return(true)
13
- expect(::ActionSubscriber::Threadpool).to_not be_busy
14
- end
15
- end
16
- end
17
-
18
- describe "ready?" do
19
- context "when all the workers are full" do
20
- it "returns false" do
21
- ::ActionSubscriber::Threadpool.new_pool(:some_dumb_pool, 2)
22
-
23
- ::ActionSubscriber::Threadpool.pools.map do |_name, pool|
24
- allow(pool).to receive(:busy_size).and_return(pool.pool_size)
25
- end
26
-
27
- expect(::ActionSubscriber::Threadpool).to_not be_ready
28
- end
29
- end
30
-
31
- context "when only one of the workers is full" do
32
- it "returns true" do
33
- pool = ::ActionSubscriber::Threadpool.new_pool(:some_other_dumb_pool, 2)
34
- allow(pool).to receive(:busy_size).and_return(2)
35
-
36
- expect(::ActionSubscriber::Threadpool).to be_ready
37
- end
38
- end
39
-
40
- context "when there are idle workers" do
41
- it "returns true" do
42
- allow(::ActionSubscriber::Threadpool.pool).to receive(:busy_size).and_return(1)
43
- expect(::ActionSubscriber::Threadpool).to be_ready
44
- end
45
- end
46
- end
47
- end