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 +4 -4
- data/action_subscriber.gemspec +1 -1
- data/lib/action_subscriber.rb +1 -0
- data/lib/action_subscriber/babou.rb +5 -2
- data/lib/action_subscriber/bunny/subscriber.rb +3 -0
- data/lib/action_subscriber/march_hare/subscriber.rb +3 -0
- data/lib/action_subscriber/threadpool.rb +4 -4
- data/lib/action_subscriber/version.rb +1 -1
- data/spec/lib/action_subscriber/threadpool_spec.rb +26 -12
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f7cb8c3f5be3679d9626c67fe5778869efa7ec2
|
4
|
+
data.tar.gz: 91024f89d188ef02703468d24711c47c073eee20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc9301af401082e92f3d5e3930e0de5e1aaa4bac0d581c4646c27ea8f20f7ef38e0c963c1038677abb966035aa5996b749fde7934bfce039143de9cfe2ecb0f8
|
7
|
+
data.tar.gz: 160e1bac79273ea4af61819402b6f789b820ce307ab4d2011a2fedd347c00c5e76cabd98646433191597f85881aae1a36ea68c59dfd4724f8c425bd93f51e056
|
data/action_subscriber.gemspec
CHANGED
data/lib/action_subscriber.rb
CHANGED
@@ -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.
|
100
|
-
puts "waiting for
|
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
|
-
|
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,32 +1,46 @@
|
|
1
1
|
describe ::ActionSubscriber::Threadpool do
|
2
2
|
describe "busy?" do
|
3
|
-
context "when the
|
3
|
+
context "when the pool is busy" do
|
4
4
|
it "returns true" do
|
5
|
-
allow(::ActionSubscriber::Threadpool
|
6
|
-
expect(::ActionSubscriber::Threadpool
|
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
|
10
|
+
context "when the pool is not busy" do
|
11
11
|
it "returns false" do
|
12
|
-
allow(::ActionSubscriber::Threadpool
|
13
|
-
expect(::ActionSubscriber::Threadpool
|
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
|
19
|
+
context "when all the workers are full" do
|
20
20
|
it "returns false" do
|
21
|
-
|
22
|
-
|
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
|
31
|
+
context "when only one of the workers is full" do
|
27
32
|
it "returns true" do
|
28
|
-
|
29
|
-
|
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.
|
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-
|
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:
|
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:
|
58
|
+
version: 0.0.9
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|