shoryuken 6.2.1 → 7.0.2
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/.github/workflows/push.yml +36 -0
- data/.github/workflows/specs.yml +49 -44
- data/.github/workflows/verify-action-pins.yml +16 -0
- data/.gitignore +4 -1
- data/.rspec +3 -1
- data/.rubocop.yml +6 -1
- data/.ruby-version +1 -0
- data/.yard-lint.yml +279 -0
- data/CHANGELOG.md +308 -139
- data/Gemfile +1 -8
- data/Gemfile.lint +9 -0
- data/Gemfile.lint.lock +69 -0
- data/README.md +16 -33
- data/Rakefile +6 -10
- data/bin/clean_sqs +52 -0
- data/bin/cli/base.rb +22 -2
- data/bin/cli/sqs.rb +74 -7
- data/bin/integrations +275 -0
- data/bin/scenario +154 -0
- data/bin/shoryuken +3 -2
- data/docker-compose.yml +6 -0
- data/lib/{shoryuken/extensions/active_job_extensions.rb → active_job/extensions.rb} +20 -6
- data/lib/active_job/queue_adapters/shoryuken_adapter.rb +208 -0
- data/lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter.rb +78 -0
- data/lib/shoryuken/active_job/current_attributes.rb +139 -0
- data/lib/shoryuken/active_job/job_wrapper.rb +28 -0
- data/lib/shoryuken/body_parser.rb +11 -1
- data/lib/shoryuken/client.rb +16 -0
- data/lib/shoryuken/default_exception_handler.rb +11 -0
- data/lib/shoryuken/default_worker_registry.rb +39 -11
- data/lib/shoryuken/environment_loader.rb +85 -15
- data/lib/shoryuken/errors.rb +36 -0
- data/lib/shoryuken/fetcher.rb +41 -3
- data/lib/shoryuken/helpers/atomic_boolean.rb +58 -0
- data/lib/shoryuken/helpers/atomic_counter.rb +104 -0
- data/lib/shoryuken/helpers/atomic_hash.rb +182 -0
- data/lib/shoryuken/helpers/hash_utils.rb +56 -0
- data/lib/shoryuken/helpers/string_utils.rb +65 -0
- data/lib/shoryuken/helpers/timer_task.rb +80 -0
- data/lib/shoryuken/inline_message.rb +22 -0
- data/lib/shoryuken/launcher.rb +55 -0
- data/lib/shoryuken/logging/base.rb +26 -0
- data/lib/shoryuken/logging/pretty.rb +25 -0
- data/lib/shoryuken/logging/without_timestamp.rb +25 -0
- data/lib/shoryuken/logging.rb +43 -15
- data/lib/shoryuken/manager.rb +84 -5
- data/lib/shoryuken/message.rb +116 -1
- data/lib/shoryuken/middleware/chain.rb +141 -43
- data/lib/shoryuken/middleware/entry.rb +30 -0
- data/lib/shoryuken/middleware/server/active_record.rb +10 -0
- data/lib/shoryuken/middleware/server/auto_delete.rb +12 -0
- data/lib/shoryuken/middleware/server/auto_extend_visibility.rb +37 -11
- data/lib/shoryuken/middleware/server/exponential_backoff_retry.rb +34 -3
- data/lib/shoryuken/middleware/server/non_retryable_exception.rb +95 -0
- data/lib/shoryuken/middleware/server/timing.rb +13 -0
- data/lib/shoryuken/options.rb +154 -13
- data/lib/shoryuken/polling/base_strategy.rb +127 -0
- data/lib/shoryuken/polling/queue_configuration.rb +103 -0
- data/lib/shoryuken/polling/strict_priority.rb +41 -0
- data/lib/shoryuken/polling/weighted_round_robin.rb +44 -0
- data/lib/shoryuken/processor.rb +37 -3
- data/lib/shoryuken/queue.rb +99 -8
- data/lib/shoryuken/runner.rb +54 -16
- data/lib/shoryuken/util.rb +32 -7
- data/lib/shoryuken/version.rb +4 -1
- data/lib/shoryuken/worker/default_executor.rb +23 -1
- data/lib/shoryuken/worker/inline_executor.rb +33 -2
- data/lib/shoryuken/worker.rb +224 -0
- data/lib/shoryuken/worker_registry.rb +35 -0
- data/lib/shoryuken.rb +27 -38
- data/renovate.json +62 -0
- data/shoryuken.gemspec +8 -4
- data/spec/integration/.rspec +1 -0
- data/spec/integration/active_job/adapter_configuration/configuration_spec.rb +26 -0
- data/spec/integration/active_job/bulk_enqueue/bulk_enqueue_spec.rb +53 -0
- data/spec/integration/active_job/current_attributes/bulk_enqueue_spec.rb +50 -0
- data/spec/integration/active_job/current_attributes/complex_types_spec.rb +55 -0
- data/spec/integration/active_job/current_attributes/empty_context_spec.rb +41 -0
- data/spec/integration/active_job/current_attributes/full_context_spec.rb +63 -0
- data/spec/integration/active_job/current_attributes/partial_context_spec.rb +57 -0
- data/spec/integration/active_job/custom_attributes/number_attributes_spec.rb +37 -0
- data/spec/integration/active_job/custom_attributes/string_attributes_spec.rb +39 -0
- data/spec/integration/active_job/error_handling/job_wrapper_spec.rb +53 -0
- data/spec/integration/active_job/fifo_and_attributes/deduplication_spec.rb +86 -0
- data/spec/integration/active_job/keyword_arguments/keyword_arguments_spec.rb +63 -0
- data/spec/integration/active_job/retry/discard_on_spec.rb +43 -0
- data/spec/integration/active_job/retry/retry_on_spec.rb +36 -0
- data/spec/integration/active_job/roundtrip/roundtrip_spec.rb +52 -0
- data/spec/integration/active_job/scheduled/scheduled_spec.rb +76 -0
- data/spec/integration/active_record_middleware/active_record_middleware_spec.rb +84 -0
- data/spec/integration/auto_delete/auto_delete_spec.rb +53 -0
- data/spec/integration/auto_extend_visibility/auto_extend_visibility_spec.rb +57 -0
- data/spec/integration/aws_config/aws_config_spec.rb +59 -0
- data/spec/integration/batch_processing/batch_processing_spec.rb +37 -0
- data/spec/integration/body_parser/json_parser_spec.rb +45 -0
- data/spec/integration/body_parser/proc_parser_spec.rb +54 -0
- data/spec/integration/body_parser/text_parser_spec.rb +43 -0
- data/spec/integration/concurrent_processing/concurrent_processing_spec.rb +45 -0
- data/spec/integration/custom_group_polling_strategy/custom_group_polling_strategy_spec.rb +87 -0
- data/spec/integration/dead_letter_queue/dead_letter_queue_spec.rb +91 -0
- data/spec/integration/exception_handlers/exception_handlers_spec.rb +69 -0
- data/spec/integration/exponential_backoff/exponential_backoff_spec.rb +67 -0
- data/spec/integration/fifo_ordering/fifo_ordering_spec.rb +44 -0
- data/spec/integration/large_payloads/large_payloads_spec.rb +30 -0
- data/spec/integration/launcher/launcher_spec.rb +40 -0
- data/spec/integration/message_attributes/message_attributes_spec.rb +54 -0
- data/spec/integration/message_operations/message_operations_spec.rb +59 -0
- data/spec/integration/middleware_chain/empty_chain_spec.rb +11 -0
- data/spec/integration/middleware_chain/execution_order_spec.rb +33 -0
- data/spec/integration/middleware_chain/removal_spec.rb +31 -0
- data/spec/integration/middleware_chain/short_circuit_spec.rb +40 -0
- data/spec/integration/non_retryable_exception/non_retryable_exception_spec.rb +149 -0
- data/spec/integration/polling_strategies/polling_strategies_spec.rb +46 -0
- data/spec/integration/queue_operations/queue_operations_spec.rb +84 -0
- data/spec/integration/rails/rails_72/Gemfile +6 -0
- data/spec/integration/rails/rails_72/activejob_adapter_spec.rb +98 -0
- data/spec/integration/rails/rails_80/Gemfile +6 -0
- data/spec/integration/rails/rails_80/activejob_adapter_spec.rb +98 -0
- data/spec/integration/rails/rails_80/continuation_spec.rb +79 -0
- data/spec/integration/rails/rails_81/Gemfile +6 -0
- data/spec/integration/rails/rails_81/activejob_adapter_spec.rb +98 -0
- data/spec/integration/rails/rails_81/continuation_spec.rb +79 -0
- data/spec/integration/retry_behavior/retry_behavior_spec.rb +45 -0
- data/spec/integration/spec_helper.rb +7 -0
- data/spec/integration/strict_priority_polling/strict_priority_polling_spec.rb +58 -0
- data/spec/integration/visibility_timeout/visibility_timeout_spec.rb +37 -0
- data/spec/integration/worker_enqueueing/worker_enqueueing_spec.rb +60 -0
- data/spec/integration/worker_groups/worker_groups_spec.rb +79 -0
- data/spec/integration/worker_lifecycle/worker_lifecycle_spec.rb +33 -0
- data/spec/integrations_helper.rb +243 -0
- data/spec/lib/active_job/extensions_spec.rb +225 -0
- data/spec/lib/active_job/queue_adapters/shoryuken_adapter_spec.rb +29 -0
- data/spec/{shoryuken/extensions/active_job_concurrent_send_adapter_spec.rb → lib/active_job/queue_adapters/shoryuken_concurrent_send_adapter_spec.rb} +5 -4
- data/spec/{shoryuken/extensions/active_job_wrapper_spec.rb → lib/shoryuken/active_job/job_wrapper_spec.rb} +6 -5
- data/spec/{shoryuken → lib/shoryuken}/body_parser_spec.rb +2 -4
- data/spec/{shoryuken → lib/shoryuken}/client_spec.rb +1 -1
- data/spec/{shoryuken → lib/shoryuken}/default_exception_handler_spec.rb +9 -10
- data/spec/{shoryuken → lib/shoryuken}/default_worker_registry_spec.rb +1 -2
- data/spec/{shoryuken → lib/shoryuken}/environment_loader_spec.rb +10 -9
- data/spec/{shoryuken → lib/shoryuken}/fetcher_spec.rb +23 -26
- data/spec/lib/shoryuken/helpers/atomic_boolean_spec.rb +196 -0
- data/spec/lib/shoryuken/helpers/atomic_counter_spec.rb +177 -0
- data/spec/lib/shoryuken/helpers/atomic_hash_spec.rb +307 -0
- data/spec/lib/shoryuken/helpers/hash_utils_spec.rb +145 -0
- data/spec/lib/shoryuken/helpers/string_utils_spec.rb +124 -0
- data/spec/lib/shoryuken/helpers/timer_task_spec.rb +298 -0
- data/spec/lib/shoryuken/helpers_integration_spec.rb +96 -0
- data/spec/lib/shoryuken/inline_message_spec.rb +196 -0
- data/spec/{shoryuken → lib/shoryuken}/launcher_spec.rb +23 -2
- data/spec/lib/shoryuken/logging_spec.rb +242 -0
- data/spec/{shoryuken → lib/shoryuken}/manager_spec.rb +1 -2
- data/spec/lib/shoryuken/message_spec.rb +109 -0
- data/spec/{shoryuken → lib/shoryuken}/middleware/chain_spec.rb +1 -1
- data/spec/lib/shoryuken/middleware/entry_spec.rb +68 -0
- data/spec/lib/shoryuken/middleware/server/active_record_spec.rb +133 -0
- data/spec/{shoryuken → lib/shoryuken}/middleware/server/auto_delete_spec.rb +1 -1
- data/spec/{shoryuken → lib/shoryuken}/middleware/server/auto_extend_visibility_spec.rb +51 -1
- data/spec/{shoryuken → lib/shoryuken}/middleware/server/exponential_backoff_retry_spec.rb +1 -1
- data/spec/lib/shoryuken/middleware/server/non_retryable_exception_spec.rb +214 -0
- data/spec/{shoryuken → lib/shoryuken}/middleware/server/timing_spec.rb +1 -1
- data/spec/{shoryuken → lib/shoryuken}/options_spec.rb +49 -6
- data/spec/lib/shoryuken/polling/base_strategy_spec.rb +280 -0
- data/spec/lib/shoryuken/polling/queue_configuration_spec.rb +195 -0
- data/spec/{shoryuken → lib/shoryuken}/polling/strict_priority_spec.rb +1 -1
- data/spec/{shoryuken → lib/shoryuken}/polling/weighted_round_robin_spec.rb +1 -1
- data/spec/{shoryuken → lib/shoryuken}/processor_spec.rb +1 -1
- data/spec/{shoryuken → lib/shoryuken}/queue_spec.rb +2 -3
- data/spec/{shoryuken → lib/shoryuken}/runner_spec.rb +1 -3
- data/spec/{shoryuken → lib/shoryuken}/util_spec.rb +2 -2
- data/spec/lib/shoryuken/version_spec.rb +17 -0
- data/spec/{shoryuken → lib/shoryuken}/worker/default_executor_spec.rb +1 -1
- data/spec/lib/shoryuken/worker/inline_executor_spec.rb +105 -0
- data/spec/lib/shoryuken/worker_registry_spec.rb +63 -0
- data/spec/{shoryuken → lib/shoryuken}/worker_spec.rb +15 -11
- data/spec/{shoryuken_spec.rb → lib/shoryuken_spec.rb} +1 -1
- data/spec/shared_examples_for_active_job.rb +40 -15
- data/spec/spec_helper.rb +48 -2
- metadata +295 -101
- data/.codeclimate.yml +0 -20
- data/.devcontainer/Dockerfile +0 -17
- data/.devcontainer/base.Dockerfile +0 -43
- data/.devcontainer/devcontainer.json +0 -35
- data/.github/FUNDING.yml +0 -12
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/stale.yml +0 -20
- data/.reek.yml +0 -5
- data/Appraisals +0 -42
- data/gemfiles/.gitignore +0 -1
- data/gemfiles/aws_sdk_core_2.gemfile +0 -21
- data/gemfiles/rails_4_2.gemfile +0 -20
- data/gemfiles/rails_5_2.gemfile +0 -21
- data/gemfiles/rails_6_0.gemfile +0 -21
- data/gemfiles/rails_6_1.gemfile +0 -21
- data/gemfiles/rails_7_0.gemfile +0 -22
- data/lib/shoryuken/core_ext.rb +0 -69
- data/lib/shoryuken/extensions/active_job_adapter.rb +0 -103
- data/lib/shoryuken/extensions/active_job_concurrent_send_adapter.rb +0 -50
- data/lib/shoryuken/polling/base.rb +0 -67
- data/shoryuken.jpg +0 -0
- data/spec/integration/launcher_spec.rb +0 -128
- data/spec/shoryuken/core_ext_spec.rb +0 -40
- data/spec/shoryuken/extensions/active_job_adapter_spec.rb +0 -7
- data/spec/shoryuken/extensions/active_job_base_spec.rb +0 -84
- data/spec/shoryuken/worker/inline_executor_spec.rb +0 -49
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Shoryuken::WorkerRegistry do
|
|
6
|
+
subject { described_class.new }
|
|
7
|
+
|
|
8
|
+
describe '#batch_receive_messages?' do
|
|
9
|
+
it 'raises NotImplementedError' do
|
|
10
|
+
expect { subject.batch_receive_messages?('test-queue') }.to raise_error(NotImplementedError)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#clear' do
|
|
15
|
+
it 'raises NotImplementedError' do
|
|
16
|
+
expect { subject.clear }.to raise_error(NotImplementedError)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#fetch_worker' do
|
|
21
|
+
it 'raises NotImplementedError' do
|
|
22
|
+
queue = 'test-queue'
|
|
23
|
+
message = double('message')
|
|
24
|
+
expect { subject.fetch_worker(queue, message) }.to raise_error(NotImplementedError)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#queues' do
|
|
29
|
+
it 'raises NotImplementedError' do
|
|
30
|
+
expect { subject.queues }.to raise_error(NotImplementedError)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#register_worker' do
|
|
35
|
+
it 'raises NotImplementedError' do
|
|
36
|
+
queue = 'test-queue'
|
|
37
|
+
worker_class = Class.new
|
|
38
|
+
expect { subject.register_worker(queue, worker_class) }.to raise_error(NotImplementedError)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#workers' do
|
|
43
|
+
it 'raises NotImplementedError' do
|
|
44
|
+
expect { subject.workers('test-queue') }.to raise_error(NotImplementedError)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context 'interface documentation' do
|
|
49
|
+
it 'defines the required interface methods' do
|
|
50
|
+
expect(subject).to respond_to(:batch_receive_messages?)
|
|
51
|
+
expect(subject).to respond_to(:clear)
|
|
52
|
+
expect(subject).to respond_to(:fetch_worker)
|
|
53
|
+
expect(subject).to respond_to(:queues)
|
|
54
|
+
expect(subject).to respond_to(:register_worker)
|
|
55
|
+
expect(subject).to respond_to(:workers)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'is designed to be subclassed' do
|
|
59
|
+
expect(described_class).to be < Object
|
|
60
|
+
expect(described_class.ancestors).to include(described_class)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe Shoryuken::Worker do
|
|
4
4
|
let(:sqs_queue) { double 'SQS Queue' }
|
|
@@ -108,14 +108,16 @@ RSpec.describe Shoryuken::Worker do
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
describe '.server_middleware' do
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
let(:fake_middleware_class) do
|
|
112
|
+
Class.new do
|
|
113
113
|
def call(*_args)
|
|
114
114
|
yield
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
+
before { fake_middleware_class }
|
|
120
|
+
|
|
119
121
|
context 'no middleware is defined in the worker' do
|
|
120
122
|
it 'returns the list of global middlewares' do
|
|
121
123
|
expect(TestWorker.server_middleware).to satisfy do |chain|
|
|
@@ -147,27 +149,29 @@ RSpec.describe Shoryuken::Worker do
|
|
|
147
149
|
end
|
|
148
150
|
|
|
149
151
|
context 'the worker modifies the chain' do
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
let(:new_test_worker3_class) do
|
|
153
|
+
ref = fake_middleware_class
|
|
154
|
+
|
|
155
|
+
Class.new do
|
|
152
156
|
include Shoryuken::Worker
|
|
153
157
|
|
|
154
158
|
server_middleware do |chain|
|
|
155
159
|
chain.remove Shoryuken::Middleware::Server::Timing
|
|
156
|
-
chain.insert_before Shoryuken::Middleware::Server::AutoDelete,
|
|
160
|
+
chain.insert_before Shoryuken::Middleware::Server::AutoDelete, ref
|
|
157
161
|
end
|
|
158
162
|
end
|
|
159
163
|
end
|
|
160
164
|
|
|
161
165
|
it 'returns the combined global and worker middlewares' do
|
|
162
|
-
expect(
|
|
166
|
+
expect(new_test_worker3_class.server_middleware).not_to satisfy do |chain|
|
|
163
167
|
chain.exists?(Shoryuken::Middleware::Server::Timing)
|
|
164
168
|
end
|
|
165
169
|
|
|
166
|
-
expect(
|
|
167
|
-
chain.exists?(
|
|
170
|
+
expect(new_test_worker3_class.server_middleware).to satisfy do |chain|
|
|
171
|
+
chain.exists?(fake_middleware_class)
|
|
168
172
|
end
|
|
169
173
|
|
|
170
|
-
expect(
|
|
174
|
+
expect(new_test_worker3_class.server_middleware).to satisfy do |chain|
|
|
171
175
|
chain.exists?(Shoryuken::Middleware::Server::AutoDelete)
|
|
172
176
|
end
|
|
173
177
|
end
|
|
@@ -182,7 +186,7 @@ RSpec.describe Shoryuken::Worker do
|
|
|
182
186
|
end
|
|
183
187
|
|
|
184
188
|
expect(Shoryuken.server_middleware).not_to satisfy do |chain|
|
|
185
|
-
chain.exists?(
|
|
189
|
+
chain.exists?(fake_middleware_class)
|
|
186
190
|
end
|
|
187
191
|
end
|
|
188
192
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'active_job'
|
|
2
|
-
require '
|
|
2
|
+
require 'active_job/extensions'
|
|
3
3
|
|
|
4
4
|
# Stand-in for a job class specified by the user
|
|
5
5
|
class TestJob < ActiveJob::Base; end
|
|
@@ -23,11 +23,11 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
23
23
|
specify do
|
|
24
24
|
expect(queue).to receive(:send_message) do |hash|
|
|
25
25
|
expect(hash[:message_deduplication_id]).to_not be
|
|
26
|
-
expect(hash[:message_attributes]['shoryuken_class'][:string_value]).to eq(
|
|
27
|
-
expect(hash[:message_attributes]['shoryuken_class'][:data_type]).to eq(
|
|
26
|
+
expect(hash[:message_attributes]['shoryuken_class'][:string_value]).to eq(Shoryuken::ActiveJob::JobWrapper.to_s)
|
|
27
|
+
expect(hash[:message_attributes]['shoryuken_class'][:data_type]).to eq('String')
|
|
28
28
|
expect(hash[:message_attributes].keys).to eq(['shoryuken_class'])
|
|
29
29
|
end
|
|
30
|
-
expect(Shoryuken).to receive(:register_worker).with(job.queue_name,
|
|
30
|
+
expect(Shoryuken).to receive(:register_worker).with(job.queue_name, Shoryuken::ActiveJob::JobWrapper)
|
|
31
31
|
|
|
32
32
|
subject.enqueue(job)
|
|
33
33
|
end
|
|
@@ -50,7 +50,7 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
50
50
|
|
|
51
51
|
expect(hash[:message_deduplication_id]).to eq(message_deduplication_id)
|
|
52
52
|
end
|
|
53
|
-
expect(Shoryuken).to receive(:register_worker).with(job.queue_name,
|
|
53
|
+
expect(Shoryuken).to receive(:register_worker).with(job.queue_name, Shoryuken::ActiveJob::JobWrapper)
|
|
54
54
|
|
|
55
55
|
subject.enqueue(job)
|
|
56
56
|
end
|
|
@@ -132,12 +132,12 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
expect(queue).to receive(:send_message) do |hash|
|
|
135
|
-
expect(hash[:message_attributes]['shoryuken_class'][:string_value]).to eq(
|
|
136
|
-
expect(hash[:message_attributes]['shoryuken_class'][:data_type]).to eq(
|
|
135
|
+
expect(hash[:message_attributes]['shoryuken_class'][:string_value]).to eq(Shoryuken::ActiveJob::JobWrapper.to_s)
|
|
136
|
+
expect(hash[:message_attributes]['shoryuken_class'][:data_type]).to eq('String')
|
|
137
137
|
expect(hash[:message_attributes]['tracer_id'][:string_value]).to eq(custom_message_attributes['tracer_id'][:string_value])
|
|
138
|
-
expect(hash[:message_attributes]['tracer_id'][:data_type]).to eq(
|
|
138
|
+
expect(hash[:message_attributes]['tracer_id'][:data_type]).to eq('String')
|
|
139
139
|
end
|
|
140
|
-
expect(Shoryuken).to receive(:register_worker).with(job.queue_name,
|
|
140
|
+
expect(Shoryuken).to receive(:register_worker).with(job.queue_name, Shoryuken::ActiveJob::JobWrapper)
|
|
141
141
|
|
|
142
142
|
subject.enqueue(job, message_attributes: custom_message_attributes)
|
|
143
143
|
end
|
|
@@ -157,7 +157,8 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
157
157
|
it 'should enqueue a message with the message_attributes specified on the job' do
|
|
158
158
|
expect(queue).to receive(:send_message) do |hash|
|
|
159
159
|
expect(hash[:message_attributes]['tracer_id']).to eq({ data_type: 'String', string_value: 'job-value' })
|
|
160
|
-
expect(hash[:message_attributes]['shoryuken_class']).to eq({ data_type: 'String',
|
|
160
|
+
expect(hash[:message_attributes]['shoryuken_class']).to eq({ data_type: 'String',
|
|
161
|
+
string_value: Shoryuken::ActiveJob::JobWrapper.to_s })
|
|
161
162
|
end
|
|
162
163
|
subject.enqueue job
|
|
163
164
|
end
|
|
@@ -185,8 +186,10 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
185
186
|
|
|
186
187
|
expect(queue).to receive(:send_message) do |hash|
|
|
187
188
|
expect(hash[:message_attributes]['tracer_id']).to be_nil
|
|
188
|
-
expect(hash[:message_attributes]['options_tracer_id']).to eq({ data_type: 'String',
|
|
189
|
-
|
|
189
|
+
expect(hash[:message_attributes]['options_tracer_id']).to eq({ data_type: 'String',
|
|
190
|
+
string_value: 'options-value' })
|
|
191
|
+
expect(hash[:message_attributes]['shoryuken_class']).to eq({ data_type: 'String',
|
|
192
|
+
string_value: Shoryuken::ActiveJob::JobWrapper.to_s })
|
|
190
193
|
end
|
|
191
194
|
subject.enqueue job, message_attributes: custom_message_attributes
|
|
192
195
|
end
|
|
@@ -225,7 +228,8 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
225
228
|
|
|
226
229
|
it 'should enqueue a message with the message_system_attributes specified on the job' do
|
|
227
230
|
expect(queue).to receive(:send_message) do |hash|
|
|
228
|
-
expect(hash[:message_system_attributes]['AWSTraceHeader']).to eq({ data_type: 'String',
|
|
231
|
+
expect(hash[:message_system_attributes]['AWSTraceHeader']).to eq({ data_type: 'String',
|
|
232
|
+
string_value: 'job-value' })
|
|
229
233
|
end
|
|
230
234
|
subject.enqueue job
|
|
231
235
|
end
|
|
@@ -253,7 +257,8 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
253
257
|
|
|
254
258
|
expect(queue).to receive(:send_message) do |hash|
|
|
255
259
|
expect(hash[:message_system_attributes]['job_trace_header']).to be_nil
|
|
256
|
-
expect(hash[:message_system_attributes]['options_trace_header']).to eq({ data_type: 'String',
|
|
260
|
+
expect(hash[:message_system_attributes]['options_trace_header']).to eq({ data_type: 'String',
|
|
261
|
+
string_value: 'options-value' })
|
|
257
262
|
end
|
|
258
263
|
subject.enqueue job, message_system_attributes: custom_message_attributes
|
|
259
264
|
end
|
|
@@ -269,13 +274,33 @@ RSpec.shared_examples 'active_job_adapters' do
|
|
|
269
274
|
expect(hash[:delay_seconds]).to eq(delay)
|
|
270
275
|
end
|
|
271
276
|
|
|
272
|
-
expect(Shoryuken).to receive(:register_worker).with(job.queue_name,
|
|
277
|
+
expect(Shoryuken).to receive(:register_worker).with(job.queue_name, Shoryuken::ActiveJob::JobWrapper)
|
|
273
278
|
|
|
274
279
|
# need to figure out what to require Time.current and N.minutes to remove the stub
|
|
275
280
|
allow(subject).to receive(:calculate_delay).and_return(delay)
|
|
276
281
|
|
|
277
282
|
subject.enqueue_at(job, nil)
|
|
278
283
|
end
|
|
284
|
+
|
|
285
|
+
context 'when fifo' do
|
|
286
|
+
let(:fifo) { true }
|
|
287
|
+
|
|
288
|
+
it 'raises FifoDelayNotSupportedError when delay is positive' do
|
|
289
|
+
allow(subject).to receive(:calculate_delay).and_return(3)
|
|
290
|
+
allow(queue).to receive(:name).and_return('test.fifo')
|
|
291
|
+
expect(queue).not_to receive(:send_message)
|
|
292
|
+
|
|
293
|
+
expect { subject.enqueue_at(job, nil) }.to raise_error(
|
|
294
|
+
Shoryuken::Errors::FifoDelayNotSupportedError, /FIFO queue.*does not support per-message delays/
|
|
295
|
+
)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
it 'does not raise when delay is zero' do
|
|
299
|
+
allow(subject).to receive(:calculate_delay).and_return(0)
|
|
300
|
+
expect(queue).to receive(:send_message).with(hash_including(delay_seconds: 0))
|
|
301
|
+
expect { subject.enqueue_at(job, nil) }.not_to raise_error
|
|
302
|
+
end
|
|
303
|
+
end
|
|
279
304
|
end
|
|
280
305
|
end
|
|
281
306
|
# rubocop:enable Metrics/BlockLength
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Warning[:performance] = true if RUBY_VERSION >= '3.3'
|
|
4
|
+
Warning[:deprecated] = true
|
|
5
|
+
$VERBOSE = true
|
|
6
|
+
|
|
7
|
+
require 'warning'
|
|
8
|
+
|
|
9
|
+
Warning.process do |warning|
|
|
10
|
+
# Only check warnings from our code (not dependencies)
|
|
11
|
+
next unless warning.include?(Dir.pwd)
|
|
12
|
+
|
|
13
|
+
# Filter out warnings we don't care about in specs
|
|
14
|
+
next if warning.include?('_spec')
|
|
15
|
+
|
|
16
|
+
# We redefine methods to simulate various scenarios in tests
|
|
17
|
+
next if warning.include?('previous definition of')
|
|
18
|
+
next if warning.include?('method redefined')
|
|
19
|
+
|
|
20
|
+
# Ignore vendor and bundle directories
|
|
21
|
+
next if warning.include?('vendor/')
|
|
22
|
+
next if warning.include?('bundle/')
|
|
23
|
+
next if warning.include?('.bundle/')
|
|
24
|
+
|
|
25
|
+
raise "Warning in your code: #{warning}"
|
|
26
|
+
end
|
|
27
|
+
|
|
1
28
|
require 'bundler/setup'
|
|
2
29
|
Bundler.setup
|
|
3
30
|
|
|
@@ -10,11 +37,30 @@ require 'shoryuken'
|
|
|
10
37
|
require 'json'
|
|
11
38
|
require 'dotenv'
|
|
12
39
|
require 'securerandom'
|
|
40
|
+
require 'ostruct'
|
|
13
41
|
Dotenv.load
|
|
14
42
|
|
|
15
|
-
|
|
43
|
+
unless ENV['SIMPLECOV_DISABLED']
|
|
16
44
|
require 'simplecov'
|
|
17
|
-
SimpleCov.start
|
|
45
|
+
SimpleCov.start do
|
|
46
|
+
add_filter '/spec/'
|
|
47
|
+
add_filter '/test_workers/'
|
|
48
|
+
add_filter '/examples/'
|
|
49
|
+
add_filter '/vendor/'
|
|
50
|
+
add_filter '/.bundle/'
|
|
51
|
+
|
|
52
|
+
add_group 'Library', 'lib/'
|
|
53
|
+
add_group 'ActiveJob', 'lib/active_job'
|
|
54
|
+
add_group 'Middleware', 'lib/shoryuken/middleware'
|
|
55
|
+
add_group 'Polling', 'lib/shoryuken/polling'
|
|
56
|
+
add_group 'Workers', 'lib/shoryuken/worker'
|
|
57
|
+
add_group 'Helpers', 'lib/shoryuken/helpers'
|
|
58
|
+
|
|
59
|
+
enable_coverage :branch
|
|
60
|
+
|
|
61
|
+
minimum_coverage 89
|
|
62
|
+
minimum_coverage_by_file 60
|
|
63
|
+
end
|
|
18
64
|
end
|
|
19
65
|
|
|
20
66
|
config_file = File.join(File.expand_path('..', __dir__), 'spec', 'shoryuken.yml')
|