shoryuken 5.2.3 → 5.3.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/lib/shoryuken/launcher.rb +7 -0
- data/lib/shoryuken/manager.rb +4 -2
- data/lib/shoryuken/message.rb +11 -28
- data/lib/shoryuken/runner.rb +4 -0
- data/lib/shoryuken/version.rb +1 -1
- data/lib/shoryuken.rb +4 -0
- data/spec/shoryuken/launcher_spec.rb +60 -0
- data/spec/shoryuken/manager_spec.rb +22 -0
- data/spec/shoryuken_spec.rb +9 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f4f8cbfdd04c4d39b7f672c549b0d112f64c99a8df4807b83083b57dab8addd
|
4
|
+
data.tar.gz: 0cfeaef14f59567382eefacb342be547a43f7dc7a118a3f824a6bdc88710ceea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ee996f0a835c46c50adaef43f413374505df454e8e696c5a1faaefdd9c28a4ed7922f620b56f800a3aad152881c66dd812bad573fec91f9d2ed9bd168c468f8
|
7
|
+
data.tar.gz: 9208b28922188d06f60ade86d0c53d56c6bedbc8577e908d5aa4a819c23cc13889fdea5dcb8875608495f2bb785f3b198bddbdb4fd93f3d6f7fa53d2f9cfec3f
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [v5.3.0] - 2021-10-31
|
2
|
+
|
3
|
+
- (Refactor) Use Forwardable within Message to avoid method boilerplate
|
4
|
+
- [#681](https://github.com/ruby-shoryuken/shoryuken/pull/681)
|
5
|
+
|
6
|
+
- Add basic health check API
|
7
|
+
- [#679](https://github.com/ruby-shoryuken/shoryuken/pull/679)
|
8
|
+
|
1
9
|
## [v5.2.3] - 2021-07-29
|
2
10
|
|
3
11
|
- Fire new `:utilization_update` event any time a worker pool's utilization changes
|
data/Gemfile
CHANGED
data/lib/shoryuken/launcher.rb
CHANGED
data/lib/shoryuken/manager.rb
CHANGED
@@ -6,6 +6,8 @@ module Shoryuken
|
|
6
6
|
# See https://github.com/phstc/shoryuken/issues/348#issuecomment-292847028
|
7
7
|
MIN_DISPATCH_INTERVAL = 0.1
|
8
8
|
|
9
|
+
attr_reader :group
|
10
|
+
|
9
11
|
def initialize(group, fetcher, polling_strategy, concurrency, executor)
|
10
12
|
@group = group
|
11
13
|
@fetcher = fetcher
|
@@ -21,12 +23,12 @@ module Shoryuken
|
|
21
23
|
dispatch_loop
|
22
24
|
end
|
23
25
|
|
24
|
-
private
|
25
|
-
|
26
26
|
def running?
|
27
27
|
@running.true? && @executor.running?
|
28
28
|
end
|
29
29
|
|
30
|
+
private
|
31
|
+
|
30
32
|
def dispatch_loop
|
31
33
|
return unless running?
|
32
34
|
|
data/lib/shoryuken/message.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
module Shoryuken
|
2
2
|
class Message
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators(:data,
|
6
|
+
:message_id,
|
7
|
+
:receipt_handle,
|
8
|
+
:md5_of_body,
|
9
|
+
:body,
|
10
|
+
:attributes,
|
11
|
+
:md5_of_message_attributes,
|
12
|
+
:message_attributes)
|
13
|
+
|
3
14
|
attr_accessor :client, :queue_url, :queue_name, :data
|
4
15
|
|
5
16
|
def initialize(client, queue, data)
|
@@ -29,33 +40,5 @@ module Shoryuken
|
|
29
40
|
visibility_timeout: timeout
|
30
41
|
)
|
31
42
|
end
|
32
|
-
|
33
|
-
def message_id
|
34
|
-
data.message_id
|
35
|
-
end
|
36
|
-
|
37
|
-
def receipt_handle
|
38
|
-
data.receipt_handle
|
39
|
-
end
|
40
|
-
|
41
|
-
def md5_of_body
|
42
|
-
data.md5_of_body
|
43
|
-
end
|
44
|
-
|
45
|
-
def body
|
46
|
-
data.body
|
47
|
-
end
|
48
|
-
|
49
|
-
def attributes
|
50
|
-
data.attributes
|
51
|
-
end
|
52
|
-
|
53
|
-
def md5_of_message_attributes
|
54
|
-
data.md5_of_message_attributes
|
55
|
-
end
|
56
|
-
|
57
|
-
def message_attributes
|
58
|
-
data.message_attributes
|
59
|
-
end
|
60
43
|
end
|
61
44
|
end
|
data/lib/shoryuken/runner.rb
CHANGED
data/lib/shoryuken/version.rb
CHANGED
data/lib/shoryuken.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shoryuken/launcher'
|
3
|
+
|
4
|
+
RSpec.describe Shoryuken::Launcher do
|
5
|
+
let(:executor) do
|
6
|
+
# We can't use Concurrent.global_io_executor in these tests since once you
|
7
|
+
# shut down a thread pool, you can't start it back up. Instead, we create
|
8
|
+
# one new thread pool executor for each spec. We use a new
|
9
|
+
# CachedThreadPool, since that most closely resembles
|
10
|
+
# Concurrent.global_io_executor
|
11
|
+
Concurrent::CachedThreadPool.new auto_terminate: true
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:first_group_manager) { double(:first_group_manager, group: 'first_group') }
|
15
|
+
let(:second_group_manager) { double(:second_group_manager, group: 'second_group') }
|
16
|
+
let(:first_queue) { "launcher_spec_#{SecureRandom.uuid}" }
|
17
|
+
let(:second_queue) { "launcher_spec_#{SecureRandom.uuid}" }
|
18
|
+
|
19
|
+
before do
|
20
|
+
Shoryuken.add_group('first_group', 1)
|
21
|
+
Shoryuken.add_group('second_group', 1)
|
22
|
+
Shoryuken.add_queue(first_queue, 1, 'first_group')
|
23
|
+
Shoryuken.add_queue(second_queue, 1, 'second_group')
|
24
|
+
allow(Shoryuken).to receive(:launcher_executor).and_return(executor)
|
25
|
+
allow(Shoryuken::Manager).to receive(:new).with('first_group', any_args).and_return(first_group_manager)
|
26
|
+
allow(Shoryuken::Manager).to receive(:new).with('second_group', any_args).and_return(second_group_manager)
|
27
|
+
allow(first_group_manager).to receive(:running?).and_return(true)
|
28
|
+
allow(second_group_manager).to receive(:running?).and_return(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#healthy?' do
|
32
|
+
context 'when all groups have managers' do
|
33
|
+
context 'when all managers are running' do
|
34
|
+
it 'returns true' do
|
35
|
+
expect(subject.healthy?).to be true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when one manager is not running' do
|
40
|
+
before do
|
41
|
+
allow(second_group_manager).to receive(:running?).and_return(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns false' do
|
45
|
+
expect(subject.healthy?).to be false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when all groups do not have managers' do
|
51
|
+
before do
|
52
|
+
allow(second_group_manager).to receive(:group).and_return('some_random_group')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns false' do
|
56
|
+
expect(subject.healthy?).to be false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -173,4 +173,26 @@ RSpec.describe Shoryuken::Manager do
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
end
|
176
|
+
|
177
|
+
describe '#running?' do
|
178
|
+
context 'when the executor is running' do
|
179
|
+
before do
|
180
|
+
allow(executor).to receive(:running?).and_return(true)
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'returns true' do
|
184
|
+
expect(subject.running?).to be true
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'when the executor is not running' do
|
189
|
+
before do
|
190
|
+
allow(executor).to receive(:running?).and_return(false)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'returns false' do
|
194
|
+
expect(subject.running?).to be false
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
176
198
|
end
|
data/spec/shoryuken_spec.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Shoryuken do
|
4
|
+
describe '.healthy?' do
|
5
|
+
before do
|
6
|
+
allow(Shoryuken::Runner).to receive(:instance).and_return(double(:instance, healthy?: :some_result))
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'delegates to the runner instance' do
|
10
|
+
expect(described_class.healthy?).to eq(:some_result)
|
11
|
+
end
|
12
|
+
end
|
4
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoryuken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Cantero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- spec/shoryuken/extensions/active_job_concurrent_send_adapter_spec.rb
|
175
175
|
- spec/shoryuken/extensions/active_job_wrapper_spec.rb
|
176
176
|
- spec/shoryuken/fetcher_spec.rb
|
177
|
+
- spec/shoryuken/launcher_spec.rb
|
177
178
|
- spec/shoryuken/manager_spec.rb
|
178
179
|
- spec/shoryuken/middleware/chain_spec.rb
|
179
180
|
- spec/shoryuken/middleware/server/auto_delete_spec.rb
|
@@ -231,6 +232,7 @@ test_files:
|
|
231
232
|
- spec/shoryuken/extensions/active_job_concurrent_send_adapter_spec.rb
|
232
233
|
- spec/shoryuken/extensions/active_job_wrapper_spec.rb
|
233
234
|
- spec/shoryuken/fetcher_spec.rb
|
235
|
+
- spec/shoryuken/launcher_spec.rb
|
234
236
|
- spec/shoryuken/manager_spec.rb
|
235
237
|
- spec/shoryuken/middleware/chain_spec.rb
|
236
238
|
- spec/shoryuken/middleware/server/auto_delete_spec.rb
|