action_subscriber 2.1.1-java → 2.1.2-java

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bb53b1d4649ffe66409823cf35a69ffc3c2f773
4
- data.tar.gz: 807b0206c26e9033012b6872e3291db06820d26d
3
+ metadata.gz: 0f7cb8c3f5be3679d9626c67fe5778869efa7ec2
4
+ data.tar.gz: 91024f89d188ef02703468d24711c47c073eee20
5
5
  SHA512:
6
- metadata.gz: 2fa2f6df1b924d98b696bea64acfbfb592dee42abfe5a17cfe2012e30ae619aeee8fce1d1d43a59d11c015f8f7153010aa5800a9219e2cb1067a47a3db6171e0
7
- data.tar.gz: a92dc35e85dc2e7bceef7d01ee9b0a463659f8360a773df06556c28078e28d6ed671f91991dc4e365fe0e6c712ddfbff06af7ec6786e4c89c7d11ebdfbc2bf3a
6
+ metadata.gz: cc9301af401082e92f3d5e3930e0de5e1aaa4bac0d581c4646c27ea8f20f7ef38e0c963c1038677abb966035aa5996b749fde7934bfce039143de9cfe2ecb0f8
7
+ data.tar.gz: 160e1bac79273ea4af61819402b6f789b820ce307ab4d2011a2fedd347c00c5e76cabd98646433191597f85881aae1a36ea68c59dfd4724f8c425bd93f51e056
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  else
27
27
  spec.add_dependency 'bunny', '>= 1.5.0'
28
28
  end
29
- spec.add_dependency 'lifeguard'
29
+ spec.add_dependency 'lifeguard', '>= 0.0.9'
30
30
  spec.add_dependency 'middleware'
31
31
  spec.add_dependency 'thor'
32
32
 
@@ -81,6 +81,7 @@ module ActionSubscriber
81
81
  logger.info " -- exchange: #{route.exchange}"
82
82
  logger.info " -- queue: #{route.queue}"
83
83
  logger.info " -- routing_key: #{route.routing_key}"
84
+ logger.info " -- threadpool: #{route.threadpool.name}, pool_size: #{route.threadpool.pool_size}"
84
85
  end
85
86
  end
86
87
  end
@@ -96,8 +96,11 @@ module ActionSubscriber
96
96
  wait_loops = 0
97
97
  ::ActionSubscriber::Babou.stop_receving_messages!
98
98
 
99
- while ::ActionSubscriber::Threadpool.pool.busy_size > 0 && wait_loops < ::ActionSubscriber.configuration.seconds_to_wait_for_graceful_shutdown
100
- puts "waiting for threadpool to empty (#{::ActionSubscriber::Threadpool.pool.busy_size})"
99
+ while ::ActionSubscriber::Threadpool.busy? && wait_loops < ::ActionSubscriber.configuration.seconds_to_wait_for_graceful_shutdown
100
+ puts "waiting for threadpools to empty:"
101
+ ::ActionSubscriber::Threadpool.pools.each do |name, pool|
102
+ puts " -- #{name} (remaining: #{pool.busy_size})" if pool.busy_size > 0
103
+ end
101
104
  Thread.pass
102
105
  wait_loops = wait_loops + 1
103
106
  sleep 1
@@ -17,6 +17,9 @@ module ActionSubscriber
17
17
  times_to_pop = [::ActionSubscriber::Threadpool.ready_size, ::ActionSubscriber.config.times_to_pop].min
18
18
  times_to_pop.times do
19
19
  queues.each do |route, queue|
20
+ # Handle busy checks on a per threadpool basis
21
+ next if route.threadpool.busy?
22
+
20
23
  delivery_info, properties, encoded_payload = queue.pop(route.queue_subscription_options)
21
24
  next unless encoded_payload # empty queue
22
25
  ::ActiveSupport::Notifications.instrument "popped_event.action_subscriber", :payload_size => encoded_payload.bytesize, :queue => queue.name
@@ -13,6 +13,9 @@ module ActionSubscriber
13
13
  times_to_pop = [::ActionSubscriber::Threadpool.ready_size, ::ActionSubscriber.config.times_to_pop].min
14
14
  times_to_pop.times do
15
15
  queues.each do |route,queue|
16
+ # Handle busy checks on a per threadpool basis
17
+ next if route.threadpool.busy?
18
+
16
19
  metadata, encoded_payload = queue.pop(route.queue_subscription_options)
17
20
  next unless encoded_payload
18
21
  ::ActiveSupport::Notifications.instrument "popped_event.action_subscriber", :payload_size => encoded_payload.bytesize, :queue => queue.name
@@ -4,15 +4,14 @@ module ActionSubscriber
4
4
  # Class Methods
5
5
  #
6
6
  def self.busy?
7
- pools.any? do |_pool_name, pool|
8
- pool.pool_size == pool.busy_size
9
- end
7
+ !ready?
10
8
  end
11
9
 
12
10
  def self.new_pool(name, pool_size = nil)
13
11
  fail ArgumentError, "#{name} already exists as a threadpool" if pools.key?(name)
14
12
  pool_size ||= ::ActionSubscriber.config.threadpool_size
15
13
  pools[name] = ::Lifeguard::InfiniteThreadpool.new(
14
+ :name => name,
16
15
  :pool_size => pool_size
17
16
  )
18
17
  end
@@ -24,13 +23,14 @@ module ActionSubscriber
24
23
  def self.pools
25
24
  @pools ||= {
26
25
  :default => ::Lifeguard::InfiniteThreadpool.new(
26
+ :name => :default,
27
27
  :pool_size => ::ActionSubscriber.config.threadpool_size
28
28
  )
29
29
  }
30
30
  end
31
31
 
32
32
  def self.ready?
33
- !busy?
33
+ pools.any? { |_pool_name, pool| !pool.busy? }
34
34
  end
35
35
 
36
36
  def self.ready_size
@@ -1,3 +1,3 @@
1
1
  module ActionSubscriber
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
@@ -1,32 +1,46 @@
1
1
  describe ::ActionSubscriber::Threadpool do
2
2
  describe "busy?" do
3
- context "when the workers are busy" do
3
+ context "when the pool is busy" do
4
4
  it "returns true" do
5
- allow(::ActionSubscriber::Threadpool.pool).to receive(:busy_size).and_return(8)
6
- expect(::ActionSubscriber::Threadpool.busy?).to eq(true)
5
+ allow(::ActionSubscriber::Threadpool).to receive(:ready?).and_return(false)
6
+ expect(::ActionSubscriber::Threadpool).to be_busy
7
7
  end
8
8
  end
9
9
 
10
- context "when there are idle workers" do
10
+ context "when the pool is not busy" do
11
11
  it "returns false" do
12
- allow(::ActionSubscriber::Threadpool.pool).to receive(:busy_size).and_return(1)
13
- expect(::ActionSubscriber::Threadpool.busy?).to eq(false)
12
+ allow(::ActionSubscriber::Threadpool).to receive(:ready?).and_return(true)
13
+ expect(::ActionSubscriber::Threadpool).to_not be_busy
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
18
  describe "ready?" do
19
- context "when the pool is busy" do
19
+ context "when all the workers are full" do
20
20
  it "returns false" do
21
- allow(::ActionSubscriber::Threadpool).to receive(:busy?).and_return true
22
- expect(::ActionSubscriber::Threadpool.ready?).to eq(false)
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
23
28
  end
24
29
  end
25
30
 
26
- context "when the pool is not busy" do
31
+ context "when only one of the workers is full" do
27
32
  it "returns true" do
28
- allow(::ActionSubscriber::Threadpool).to receive(:busy?).and_return false
29
- expect(::ActionSubscriber::Threadpool.ready?).to eq(true)
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
30
44
  end
31
45
  end
32
46
  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: 2.1.1
4
+ version: 2.1.2
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-02-19 00:00:00.000000000 Z
15
+ date: 2016-02-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  requirement: !ruby/object:Gem::Requirement
@@ -47,7 +47,7 @@ dependencies:
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '0'
50
+ version: 0.0.9
51
51
  name: lifeguard
52
52
  prerelease: false
53
53
  type: :runtime
@@ -55,7 +55,7 @@ dependencies:
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
- version: '0'
58
+ version: 0.0.9
59
59
  - !ruby/object:Gem::Dependency
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements: