shoryuken 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/specs.yml +5 -2
- data/.github/workflows/stale.yml +1 -1
- data/Appraisals +6 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +1 -1
- data/README.md +19 -1
- data/gemfiles/aws_sdk_core_2.gemfile +1 -1
- data/gemfiles/rails_7_0.gemfile +22 -0
- data/lib/shoryuken/default_exception_handler.rb +10 -0
- data/lib/shoryuken/extensions/active_job_adapter.rb +5 -2
- data/lib/shoryuken/extensions/active_job_extensions.rb +1 -1
- data/lib/shoryuken/launcher.rb +7 -3
- data/lib/shoryuken/logging.rb +2 -2
- data/lib/shoryuken/options.rb +5 -3
- data/lib/shoryuken/processor.rb +1 -2
- data/lib/shoryuken/version.rb +1 -1
- data/lib/shoryuken.rb +3 -0
- data/shoryuken.gemspec +1 -1
- data/spec/shared_examples_for_active_job.rb +4 -2
- data/spec/shoryuken/default_exception_handler_spec.rb +71 -0
- data/spec/shoryuken/extensions/active_job_base_spec.rb +1 -1
- data/spec/shoryuken/fetcher_spec.rb +12 -12
- data/spec/shoryuken/launcher_spec.rb +46 -1
- data/spec/spec_helper.rb +2 -0
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3ab903a9490d367ced7d0d70cb3f3aae142abc17dc466f2248b64ee5566773
|
4
|
+
data.tar.gz: e3f84b09a3e3a888ba280ade138fc8b9c902a0d39d27188ac6e6576a19a6e482
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7273ea2e72c35dd4c443d3376da6e787e0c3c86ee4a048700a73391e662c631e0509bd22bf7cf7016d2bfe9cf35273706037b3621fc4cd5c6c2b19c7a39bb727
|
7
|
+
data.tar.gz: d08532edb206f643cf3fec6ff197efc84768871f90a7ef185ebc1030f5027b8dd333642036a601e8884225a750cd4666bfbc349cb7f2a576a0f2e8fc9d0ece48
|
data/.github/workflows/specs.yml
CHANGED
@@ -9,7 +9,7 @@ jobs:
|
|
9
9
|
name: All Specs
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
|
-
ruby: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
12
|
+
ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
|
13
13
|
gemfile: ['Gemfile', 'gemfiles/aws_sdk_core_2.gemfile']
|
14
14
|
runs-on: ubuntu-20.04
|
15
15
|
services:
|
@@ -34,7 +34,7 @@ jobs:
|
|
34
34
|
name: Rails Specs
|
35
35
|
strategy:
|
36
36
|
matrix:
|
37
|
-
rails: ['4.2', '5.2', '6.0', '6.1']
|
37
|
+
rails: ['4.2', '5.2', '6.0', '6.1', '7.0']
|
38
38
|
include:
|
39
39
|
- rails: '4.2'
|
40
40
|
ruby: '2.2'
|
@@ -48,6 +48,9 @@ jobs:
|
|
48
48
|
- rails: '6.1'
|
49
49
|
ruby: '3.0'
|
50
50
|
gemfile: gemfiles/rails_6_1.gemfile
|
51
|
+
- rails: '7.0'
|
52
|
+
ruby: '3.1'
|
53
|
+
gemfile: gemfiles/rails_7_0.gemfile
|
51
54
|
runs-on: ubuntu-20.04
|
52
55
|
env:
|
53
56
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
data/.github/workflows/stale.yml
CHANGED
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
issues: write
|
11
11
|
pull-requests: write
|
12
12
|
steps:
|
13
|
-
- uses: actions/stale@
|
13
|
+
- uses: actions/stale@v8
|
14
14
|
with:
|
15
15
|
stale-issue-message: This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
|
16
16
|
stale-pr-message: This PR is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## [v6.1.0] - 2023-11-01
|
2
|
+
|
3
|
+
- Add GitHub Codespaces
|
4
|
+
- [#698](https://github.com/ruby-shoryuken/shoryuken/pull/698)
|
5
|
+
|
6
|
+
- Fix spec for ruby 3.0
|
7
|
+
- [#727](https://github.com/ruby-shoryuken/shoryuken/pull/727)
|
8
|
+
|
9
|
+
- Upgrade test matrix. Add Ruby 3.1, Ruby 3.2 and Rails 7
|
10
|
+
- [#739](https://github.com/ruby-shoryuken/shoryuken/pull/739)
|
11
|
+
|
12
|
+
- Fire stopped event after executor is stopped
|
13
|
+
- [#741](https://github.com/ruby-shoryuken/shoryuken/pull/741)
|
14
|
+
|
15
|
+
- Allow setup custom exception handlers for failing jobs
|
16
|
+
- [#742](https://github.com/ruby-shoryuken/shoryuken/pull/742)
|
17
|
+
|
18
|
+
- Configure dependabot to update GH Actions
|
19
|
+
- [#745](https://github.com/ruby-shoryuken/shoryuken/pull/745)
|
20
|
+
|
21
|
+
- Stop the dispatching of new messages when a SIGTERM signal has been received
|
22
|
+
- [#750](https://github.com/ruby-shoryuken/shoryuken/pull/750)
|
23
|
+
|
1
24
|
## [v6.0.0] - 2022-02-18
|
2
25
|
|
3
26
|
- Breaking changes: Initialize Rails before parsing config file
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
**I'm looking for Shoryuken maintainers, are you interested on helping to maintain Shoryuken?
|
1
|
+
**I'm looking for Shoryuken maintainers, are you interested on helping to maintain Shoryuken? [Join our Slack](https://join.slack.com/t/shoryuken/shared_invite/zt-19xjq3iqc-KmoJ6eU6~qvZNqcLzIrjww)**
|
2
2
|
|
3
3
|
# Shoryuken
|
4
4
|
|
@@ -86,3 +86,21 @@ To run integration specs, start a mock SQS server on `localhost:5000`. One such
|
|
86
86
|
```sh
|
87
87
|
bundle exec rake spec:integration
|
88
88
|
```
|
89
|
+
|
90
|
+
### To release a new version
|
91
|
+
|
92
|
+
Compare latest tag with HEAD:
|
93
|
+
|
94
|
+
```sh
|
95
|
+
git log $(git describe --tags --abbrev=0)..HEAD --oneline
|
96
|
+
```
|
97
|
+
|
98
|
+
then update CHANGELOG.md.
|
99
|
+
|
100
|
+
Update version in `lib/shoryuken/version.rb` with the appropriate version number [SEMVER](https://semver.org/).
|
101
|
+
|
102
|
+
then run:
|
103
|
+
|
104
|
+
```sh
|
105
|
+
bundle exec rake release
|
106
|
+
```
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem "activejob", "~> 7.0"
|
7
|
+
gem "aws-sdk-core", "~> 3"
|
8
|
+
gem "aws-sdk-sqs"
|
9
|
+
gem "codeclimate-test-reporter", require: nil
|
10
|
+
gem "httparty"
|
11
|
+
gem "multi_xml"
|
12
|
+
gem "simplecov"
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
|
17
|
+
gem "rubocop"
|
18
|
+
gem "pry", ">= 0.14.2"
|
19
|
+
gem "pry-byebug", ">= 3.10.1"
|
20
|
+
end
|
21
|
+
|
22
|
+
gemspec path: "../"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Shoryuken
|
2
|
+
class DefaultExceptionHandler
|
3
|
+
extend Util
|
4
|
+
|
5
|
+
def self.call(exception, _queue, _sqs_msg)
|
6
|
+
logger.error { "Processor failed: #{exception.message}" }
|
7
|
+
logger.error { exception.backtrace.join("\n") } if exception.backtrace
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -66,8 +66,11 @@ module ActiveJob
|
|
66
66
|
}
|
67
67
|
|
68
68
|
if queue.fifo?
|
69
|
-
# See https://github.com/
|
70
|
-
|
69
|
+
# See https://github.com/ruby-shoryuken/shoryuken/issues/457 and
|
70
|
+
# https://github.com/ruby-shoryuken/shoryuken/pull/750#issuecomment-1781317929
|
71
|
+
msg[:message_deduplication_id] = Digest::SHA256.hexdigest(
|
72
|
+
JSON.dump(body.except('job_id', 'enqueued_at'))
|
73
|
+
)
|
71
74
|
end
|
72
75
|
|
73
76
|
msg.merge(job_params.except(:message_attributes))
|
@@ -11,7 +11,7 @@ module Shoryuken
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
# Initializes SQS SendMessage parameters on instances of
|
14
|
+
# Initializes SQS SendMessage parameters on instances of ActiveJob::Base
|
15
15
|
# to the empty hash, and populates it whenever `#enqueue` is called, such
|
16
16
|
# as when using ActiveJob::Base.set.
|
17
17
|
module SQSSendMessageParametersSupport
|
data/lib/shoryuken/launcher.rb
CHANGED
@@ -16,11 +16,13 @@ module Shoryuken
|
|
16
16
|
def stop!
|
17
17
|
initiate_stop
|
18
18
|
|
19
|
-
|
19
|
+
# Don't await here so the timeout below is not delayed
|
20
|
+
stop_new_dispatching
|
20
21
|
|
21
|
-
|
22
|
+
executor.shutdown
|
23
|
+
executor.kill unless executor.wait_for_termination(Shoryuken.options[:timeout])
|
22
24
|
|
23
|
-
|
25
|
+
fire_event(:stopped)
|
24
26
|
end
|
25
27
|
|
26
28
|
def stop
|
@@ -33,6 +35,8 @@ module Shoryuken
|
|
33
35
|
|
34
36
|
executor.shutdown
|
35
37
|
executor.wait_for_termination
|
38
|
+
|
39
|
+
fire_event(:stopped)
|
36
40
|
end
|
37
41
|
|
38
42
|
def healthy?
|
data/lib/shoryuken/logging.rb
CHANGED
@@ -30,11 +30,11 @@ module Shoryuken
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.logger
|
33
|
-
@logger
|
33
|
+
@logger ||= initialize_logger
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.logger=(log)
|
37
|
-
@logger = (log
|
37
|
+
@logger = (log || Logger.new('/dev/null'))
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/lib/shoryuken/options.rb
CHANGED
@@ -11,19 +11,21 @@ module Shoryuken
|
|
11
11
|
dispatch: [],
|
12
12
|
utilization_update: [],
|
13
13
|
quiet: [],
|
14
|
-
shutdown: []
|
14
|
+
shutdown: [],
|
15
|
+
stopped: []
|
15
16
|
}
|
16
17
|
}.freeze
|
17
18
|
|
18
19
|
attr_accessor :active_job_queue_name_prefixing, :cache_visibility_timeout, :groups,
|
19
20
|
:launcher_executor,
|
20
|
-
:start_callback, :stop_callback, :worker_executor, :worker_registry
|
21
|
+
:start_callback, :stop_callback, :worker_executor, :worker_registry, :exception_handlers
|
21
22
|
attr_writer :default_worker_options, :sqs_client
|
22
23
|
attr_reader :sqs_client_receive_message_opts
|
23
24
|
|
24
25
|
def initialize
|
25
26
|
self.groups = {}
|
26
27
|
self.worker_registry = DefaultWorkerRegistry.new
|
28
|
+
self.exception_handlers = [DefaultExceptionHandler]
|
27
29
|
self.active_job_queue_name_prefixing = false
|
28
30
|
self.worker_executor = Worker::DefaultExecutor
|
29
31
|
self.cache_visibility_timeout = false
|
@@ -134,7 +136,7 @@ module Shoryuken
|
|
134
136
|
end
|
135
137
|
|
136
138
|
# Register a block to run at a point in the Shoryuken lifecycle.
|
137
|
-
# :startup, :quiet or :
|
139
|
+
# :startup, :quiet, :shutdown or :stopped are valid events.
|
138
140
|
#
|
139
141
|
# Shoryuken.configure_server do |config|
|
140
142
|
# config.on(:shutdown) do
|
data/lib/shoryuken/processor.rb
CHANGED
@@ -22,8 +22,7 @@ module Shoryuken
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
rescue Exception => ex
|
25
|
-
|
26
|
-
logger.error { ex.backtrace.join("\n") } unless ex.backtrace.nil?
|
25
|
+
Array(Shoryuken.exception_handlers).each { |handler| handler.call(ex, queue, sqs_msg) }
|
27
26
|
|
28
27
|
raise
|
29
28
|
end
|
data/lib/shoryuken/version.rb
CHANGED
data/lib/shoryuken.rb
CHANGED
@@ -23,6 +23,7 @@ require 'shoryuken/worker/default_executor'
|
|
23
23
|
require 'shoryuken/worker/inline_executor'
|
24
24
|
require 'shoryuken/worker_registry'
|
25
25
|
require 'shoryuken/default_worker_registry'
|
26
|
+
require 'shoryuken/default_exception_handler'
|
26
27
|
require 'shoryuken/middleware/chain'
|
27
28
|
require 'shoryuken/middleware/server/auto_delete'
|
28
29
|
Shoryuken::Middleware::Server.autoload :AutoExtendVisibility, 'shoryuken/middleware/server/auto_extend_visibility'
|
@@ -73,6 +74,8 @@ module Shoryuken
|
|
73
74
|
:sqs_client=,
|
74
75
|
:sqs_client_receive_message_opts,
|
75
76
|
:sqs_client_receive_message_opts=,
|
77
|
+
:exception_handlers,
|
78
|
+
:exception_handlers=,
|
76
79
|
:options,
|
77
80
|
:logger,
|
78
81
|
:register_worker,
|
data/shoryuken.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Pablo Cantero']
|
10
10
|
spec.email = ['pablo@pablocantero.com']
|
11
11
|
spec.description = spec.summary = 'Shoryuken is a super efficient AWS SQS thread based message processor'
|
12
|
-
spec.homepage = 'https://github.com/
|
12
|
+
spec.homepage = 'https://github.com/ruby-shoryuken/shoryuken'
|
13
13
|
spec.license = 'LGPL-3.0'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -42,9 +42,11 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
42
42
|
context 'when fifo' do
|
43
43
|
let(:fifo) { true }
|
44
44
|
|
45
|
-
it 'does not include job_id in the deduplication_id' do
|
45
|
+
it 'does not include job_id and enqueued_at in the deduplication_id' do
|
46
46
|
expect(queue).to receive(:send_message) do |hash|
|
47
|
-
message_deduplication_id = Digest::SHA256.hexdigest(
|
47
|
+
message_deduplication_id = Digest::SHA256.hexdigest(
|
48
|
+
JSON.dump(job.serialize.except('job_id', 'enqueued_at'))
|
49
|
+
)
|
48
50
|
|
49
51
|
expect(hash[:message_deduplication_id]).to eq(message_deduplication_id)
|
50
52
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/BlockLength
|
4
|
+
RSpec.describe Shoryuken::DefaultExceptionHandler do
|
5
|
+
class CustomErrorHandler
|
6
|
+
extend Shoryuken::Util
|
7
|
+
|
8
|
+
def self.call(_ex, queue, _msg)
|
9
|
+
logger.error("#{queue.to_s} failed to process the message")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
before do
|
14
|
+
Shoryuken.worker_executor = Shoryuken::Worker::InlineExecutor
|
15
|
+
allow(manager).to receive(:async).and_return(manager)
|
16
|
+
allow(manager).to receive(:real_thread)
|
17
|
+
allow(Shoryuken::Client).to receive(:queues).with(queue).and_return(sqs_queue)
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
Shoryuken.worker_executor = Shoryuken::Worker::DefaultExecutor
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:manager) { double Shoryuken::Manager }
|
25
|
+
let(:sqs_queue) { double Shoryuken::Queue, visibility_timeout: 30 }
|
26
|
+
let(:queue) { 'default' }
|
27
|
+
|
28
|
+
let(:sqs_msg) do
|
29
|
+
double(
|
30
|
+
Shoryuken::Message,
|
31
|
+
queue_url: queue,
|
32
|
+
body: 'test',
|
33
|
+
message_attributes: {},
|
34
|
+
message_id: SecureRandom.uuid,
|
35
|
+
receipt_handle: SecureRandom.uuid
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
subject { Shoryuken::Processor.new(queue, sqs_msg) }
|
40
|
+
|
41
|
+
context "with default handler" do
|
42
|
+
before do
|
43
|
+
Shoryuken.exception_handlers = described_class
|
44
|
+
end
|
45
|
+
|
46
|
+
it "logs an error message" do
|
47
|
+
expect(Shoryuken::Logging.logger).to receive(:error).twice
|
48
|
+
|
49
|
+
allow_any_instance_of(TestWorker).to receive(:perform).and_raise(StandardError, "error")
|
50
|
+
allow(sqs_msg).to receive(:body)
|
51
|
+
|
52
|
+
expect { subject.process }.to raise_error(StandardError)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with custom handler" do
|
57
|
+
before do
|
58
|
+
Shoryuken.exception_handlers = [described_class, CustomErrorHandler]
|
59
|
+
end
|
60
|
+
|
61
|
+
it "logs default and custom error messages" do
|
62
|
+
expect(Shoryuken::Logging.logger).to receive(:error).twice
|
63
|
+
expect(Shoryuken::Logging.logger).to receive(:error).with("default failed to process the message").once
|
64
|
+
|
65
|
+
allow_any_instance_of(TestWorker).to receive(:perform).and_raise(StandardError, "error")
|
66
|
+
allow(sqs_msg).to receive(:body)
|
67
|
+
|
68
|
+
expect { subject.process }.to raise_error(StandardError)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -18,7 +18,7 @@ RSpec.describe ActiveJob::Base do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#perform_now' do
|
21
|
-
it 'allows
|
21
|
+
it 'allows keyword args' do
|
22
22
|
collaborator = double 'worker collaborator'
|
23
23
|
subject.send(:define_method, :perform) do |**kwargs|
|
24
24
|
collaborator.foo(**kwargs)
|
@@ -28,12 +28,12 @@ RSpec.describe Shoryuken::Fetcher do
|
|
28
28
|
|
29
29
|
Shoryuken.sqs_client_receive_message_opts[group] = { wait_time_seconds: 10 }
|
30
30
|
|
31
|
-
expect(queue).to receive(:receive_messages).with(
|
31
|
+
expect(queue).to receive(:receive_messages).with({
|
32
32
|
wait_time_seconds: 10,
|
33
33
|
max_number_of_messages: limit,
|
34
34
|
message_attribute_names: ['All'],
|
35
35
|
attribute_names: ['All']
|
36
|
-
).and_return([])
|
36
|
+
}).and_return([])
|
37
37
|
|
38
38
|
subject.fetch(queue_config, limit)
|
39
39
|
end
|
@@ -62,11 +62,11 @@ RSpec.describe Shoryuken::Fetcher do
|
|
62
62
|
|
63
63
|
Shoryuken.sqs_client_receive_message_opts[queue_name] = { max_number_of_messages: 1 }
|
64
64
|
|
65
|
-
expect(queue).to receive(:receive_messages).with(
|
65
|
+
expect(queue).to receive(:receive_messages).with({
|
66
66
|
max_number_of_messages: 1,
|
67
67
|
message_attribute_names: ['All'],
|
68
68
|
attribute_names: ['All']
|
69
|
-
).and_return([])
|
69
|
+
}).and_return([])
|
70
70
|
|
71
71
|
subject.fetch(queue_config, limit)
|
72
72
|
end
|
@@ -78,11 +78,11 @@ RSpec.describe Shoryuken::Fetcher do
|
|
78
78
|
|
79
79
|
Shoryuken.sqs_client_receive_message_opts[queue_name] = { max_number_of_messages: 20 }
|
80
80
|
|
81
|
-
expect(queue).to receive(:receive_messages).with(
|
81
|
+
expect(queue).to receive(:receive_messages).with({
|
82
82
|
max_number_of_messages: limit,
|
83
83
|
message_attribute_names: ['All'],
|
84
84
|
attribute_names: ['All']
|
85
|
-
).and_return([])
|
85
|
+
}).and_return([])
|
86
86
|
|
87
87
|
subject.fetch(queue_config, limit)
|
88
88
|
end
|
@@ -93,9 +93,9 @@ RSpec.describe Shoryuken::Fetcher do
|
|
93
93
|
|
94
94
|
specify do
|
95
95
|
allow(Shoryuken::Client).to receive(:queues).with(queue_name).and_return(queue)
|
96
|
-
expect(queue).to receive(:receive_messages).with(
|
96
|
+
expect(queue).to receive(:receive_messages).with({
|
97
97
|
max_number_of_messages: described_class::FETCH_LIMIT, attribute_names: ['All'], message_attribute_names: ['All']
|
98
|
-
).and_return([])
|
98
|
+
}).and_return([])
|
99
99
|
|
100
100
|
subject.fetch(queue_config, limit)
|
101
101
|
end
|
@@ -109,9 +109,9 @@ RSpec.describe Shoryuken::Fetcher do
|
|
109
109
|
# see https://github.com/phstc/shoryuken/pull/530
|
110
110
|
|
111
111
|
allow(Shoryuken::Client).to receive(:queues).with(queue_name).and_return(queue)
|
112
|
-
expect(queue).to receive(:receive_messages).with(
|
112
|
+
expect(queue).to receive(:receive_messages).with({
|
113
113
|
max_number_of_messages: 1, attribute_names: ['All'], message_attribute_names: ['All']
|
114
|
-
).and_return([])
|
114
|
+
}).and_return([])
|
115
115
|
|
116
116
|
subject.fetch(queue_config, limit)
|
117
117
|
end
|
@@ -123,9 +123,9 @@ RSpec.describe Shoryuken::Fetcher do
|
|
123
123
|
allow(Shoryuken::Client).to receive(:queues).with(queue_name).and_return(queue)
|
124
124
|
allow(Shoryuken.worker_registry).to receive(:batch_receive_messages?).with(queue.name).and_return(true)
|
125
125
|
|
126
|
-
expect(queue).to receive(:receive_messages).with(
|
126
|
+
expect(queue).to receive(:receive_messages).with({
|
127
127
|
max_number_of_messages: limit, attribute_names: ['All'], message_attribute_names: ['All']
|
128
|
-
).and_return([])
|
128
|
+
}).and_return([])
|
129
129
|
|
130
130
|
subject.fetch(queue_config, limit)
|
131
131
|
end
|
@@ -57,4 +57,49 @@ RSpec.describe Shoryuken::Launcher do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
|
+
describe '#stop' do
|
62
|
+
before do
|
63
|
+
allow(first_group_manager).to receive(:stop_new_dispatching)
|
64
|
+
allow(first_group_manager).to receive(:await_dispatching_in_progress)
|
65
|
+
allow(second_group_manager).to receive(:stop_new_dispatching)
|
66
|
+
allow(second_group_manager).to receive(:await_dispatching_in_progress)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'fires quiet, shutdown and stopped event' do
|
70
|
+
allow(subject).to receive(:fire_event)
|
71
|
+
subject.stop
|
72
|
+
expect(subject).to have_received(:fire_event).with(:quiet, true)
|
73
|
+
expect(subject).to have_received(:fire_event).with(:shutdown, true)
|
74
|
+
expect(subject).to have_received(:fire_event).with(:stopped)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'stops the managers' do
|
78
|
+
subject.stop
|
79
|
+
expect(first_group_manager).to have_received(:stop_new_dispatching)
|
80
|
+
expect(second_group_manager).to have_received(:stop_new_dispatching)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#stop!' do
|
85
|
+
before do
|
86
|
+
allow(first_group_manager).to receive(:stop_new_dispatching)
|
87
|
+
allow(first_group_manager).to receive(:await_dispatching_in_progress)
|
88
|
+
allow(second_group_manager).to receive(:stop_new_dispatching)
|
89
|
+
allow(second_group_manager).to receive(:await_dispatching_in_progress)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'fires shutdown and stopped event' do
|
93
|
+
allow(subject).to receive(:fire_event)
|
94
|
+
subject.stop!
|
95
|
+
expect(subject).to have_received(:fire_event).with(:shutdown, true)
|
96
|
+
expect(subject).to have_received(:fire_event).with(:stopped)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'stops the managers' do
|
100
|
+
subject.stop!
|
101
|
+
expect(first_group_manager).to have_received(:stop_new_dispatching)
|
102
|
+
expect(second_group_manager).to have_received(:stop_new_dispatching)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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: 6.
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Cantero
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- ".devcontainer/base.Dockerfile"
|
108
108
|
- ".devcontainer/devcontainer.json"
|
109
109
|
- ".github/FUNDING.yml"
|
110
|
+
- ".github/dependabot.yml"
|
110
111
|
- ".github/workflows/specs.yml"
|
111
112
|
- ".github/workflows/stale.yml"
|
112
113
|
- ".gitignore"
|
@@ -130,10 +131,12 @@ files:
|
|
130
131
|
- gemfiles/rails_5_2.gemfile
|
131
132
|
- gemfiles/rails_6_0.gemfile
|
132
133
|
- gemfiles/rails_6_1.gemfile
|
134
|
+
- gemfiles/rails_7_0.gemfile
|
133
135
|
- lib/shoryuken.rb
|
134
136
|
- lib/shoryuken/body_parser.rb
|
135
137
|
- lib/shoryuken/client.rb
|
136
138
|
- lib/shoryuken/core_ext.rb
|
139
|
+
- lib/shoryuken/default_exception_handler.rb
|
137
140
|
- lib/shoryuken/default_worker_registry.rb
|
138
141
|
- lib/shoryuken/environment_loader.rb
|
139
142
|
- lib/shoryuken/extensions/active_job_adapter.rb
|
@@ -171,6 +174,7 @@ files:
|
|
171
174
|
- spec/shoryuken/body_parser_spec.rb
|
172
175
|
- spec/shoryuken/client_spec.rb
|
173
176
|
- spec/shoryuken/core_ext_spec.rb
|
177
|
+
- spec/shoryuken/default_exception_handler_spec.rb
|
174
178
|
- spec/shoryuken/default_worker_registry_spec.rb
|
175
179
|
- spec/shoryuken/environment_loader_spec.rb
|
176
180
|
- spec/shoryuken/extensions/active_job_adapter_spec.rb
|
@@ -199,11 +203,11 @@ files:
|
|
199
203
|
- spec/spec_helper.rb
|
200
204
|
- test_workers/endless_interruptive_worker.rb
|
201
205
|
- test_workers/endless_uninterruptive_worker.rb
|
202
|
-
homepage: https://github.com/
|
206
|
+
homepage: https://github.com/ruby-shoryuken/shoryuken
|
203
207
|
licenses:
|
204
208
|
- LGPL-3.0
|
205
209
|
metadata: {}
|
206
|
-
post_install_message:
|
210
|
+
post_install_message:
|
207
211
|
rdoc_options: []
|
208
212
|
require_paths:
|
209
213
|
- lib
|
@@ -218,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
222
|
- !ruby/object:Gem::Version
|
219
223
|
version: '0'
|
220
224
|
requirements: []
|
221
|
-
rubygems_version: 3.
|
222
|
-
signing_key:
|
225
|
+
rubygems_version: 3.3.26
|
226
|
+
signing_key:
|
223
227
|
specification_version: 4
|
224
228
|
summary: Shoryuken is a super efficient AWS SQS thread based message processor
|
225
229
|
test_files:
|
@@ -229,6 +233,7 @@ test_files:
|
|
229
233
|
- spec/shoryuken/body_parser_spec.rb
|
230
234
|
- spec/shoryuken/client_spec.rb
|
231
235
|
- spec/shoryuken/core_ext_spec.rb
|
236
|
+
- spec/shoryuken/default_exception_handler_spec.rb
|
232
237
|
- spec/shoryuken/default_worker_registry_spec.rb
|
233
238
|
- spec/shoryuken/environment_loader_spec.rb
|
234
239
|
- spec/shoryuken/extensions/active_job_adapter_spec.rb
|