shoryuken 3.1.1 → 3.2.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/.rubocop.yml +1 -1
- data/.travis.yml +13 -3
- data/CHANGELOG.md +82 -1
- data/Gemfile +5 -2
- data/Gemfile.aws-sdk-core-v2 +13 -0
- data/bin/cli/sqs.rb +8 -4
- data/bin/shoryuken +2 -1
- data/lib/shoryuken/body_parser.rb +27 -0
- data/lib/shoryuken/environment_loader.rb +25 -11
- data/lib/shoryuken/fetcher.rb +40 -13
- data/lib/shoryuken/launcher.rb +4 -20
- data/lib/shoryuken/logging.rb +0 -5
- data/lib/shoryuken/manager.rb +31 -22
- data/lib/shoryuken/middleware/chain.rb +4 -0
- data/lib/shoryuken/middleware/server/auto_extend_visibility.rb +2 -5
- data/lib/shoryuken/middleware/server/timing.rb +12 -14
- data/lib/shoryuken/options.rb +25 -1
- data/lib/shoryuken/processor.rb +9 -21
- data/lib/shoryuken/queue.rb +12 -5
- data/lib/shoryuken/runner.rb +3 -1
- data/lib/shoryuken/util.rb +3 -3
- data/lib/shoryuken/version.rb +1 -1
- data/lib/shoryuken/worker/default_executor.rb +33 -0
- data/lib/shoryuken/worker/inline_executor.rb +28 -0
- data/lib/shoryuken/worker.rb +68 -31
- data/lib/shoryuken.rb +14 -1
- data/shoryuken.gemspec +1 -1
- data/spec/shoryuken/body_parser_spec.rb +89 -0
- data/spec/shoryuken/environment_loader_spec.rb +32 -3
- data/spec/shoryuken/fetcher_spec.rb +61 -9
- data/spec/shoryuken/manager_spec.rb +31 -18
- data/spec/shoryuken/middleware/chain_spec.rb +16 -4
- data/spec/shoryuken/middleware/server/timing_spec.rb +5 -3
- data/spec/shoryuken/options_spec.rb +80 -0
- data/spec/shoryuken/processor_spec.rb +15 -97
- data/spec/shoryuken/queue_spec.rb +43 -32
- data/spec/shoryuken/util_spec.rb +25 -1
- data/spec/shoryuken/worker/default_executor_spec.rb +100 -0
- data/spec/shoryuken/worker/inline_executor_spec.rb +23 -0
- data/spec/shoryuken/worker_spec.rb +32 -91
- data/spec/spec_helper.rb +5 -0
- metadata +15 -5
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Shoryuken::Worker::InlineExecutor do
|
|
4
|
+
before do
|
|
5
|
+
Shoryuken.worker_executor = described_class
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe '.perform_async' do
|
|
9
|
+
specify do
|
|
10
|
+
expect_any_instance_of(TestWorker).to receive(:perform)
|
|
11
|
+
|
|
12
|
+
TestWorker.perform_async('test')
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe '.perform_in' do
|
|
17
|
+
specify do
|
|
18
|
+
expect_any_instance_of(TestWorker).to receive(:perform)
|
|
19
|
+
|
|
20
|
+
TestWorker.perform_in(60, 'test')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
RSpec.describe
|
|
3
|
+
RSpec.describe Shoryuken::Worker do
|
|
4
4
|
let(:sqs_queue) { double 'SQS Queue' }
|
|
5
5
|
let(:queue) { 'default' }
|
|
6
6
|
|
|
@@ -8,96 +8,6 @@ RSpec.describe 'Shoryuken::Worker' do
|
|
|
8
8
|
allow(Shoryuken::Client).to receive(:queues).with(queue).and_return(sqs_queue)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
describe '.perform_in' do
|
|
12
|
-
it 'delays a message' do
|
|
13
|
-
expect(sqs_queue).to receive(:send_message).with(
|
|
14
|
-
message_attributes: {
|
|
15
|
-
'shoryuken_class' => {
|
|
16
|
-
string_value: TestWorker.to_s,
|
|
17
|
-
data_type: 'String'
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
message_body: 'message',
|
|
21
|
-
delay_seconds: 60)
|
|
22
|
-
|
|
23
|
-
TestWorker.perform_in(60, 'message')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'raises an exception' do
|
|
27
|
-
expect {
|
|
28
|
-
TestWorker.perform_in(901, 'message')
|
|
29
|
-
}.to raise_error 'The maximum allowed delay is 15 minutes'
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe '.perform_at' do
|
|
34
|
-
it 'delays a message' do
|
|
35
|
-
expect(sqs_queue).to receive(:send_message).with(
|
|
36
|
-
message_attributes: {
|
|
37
|
-
'shoryuken_class' => {
|
|
38
|
-
string_value: TestWorker.to_s,
|
|
39
|
-
data_type: 'String'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
message_body: 'message',
|
|
43
|
-
delay_seconds: 60)
|
|
44
|
-
|
|
45
|
-
TestWorker.perform_in(Time.now + 60, 'message')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'raises an exception' do
|
|
49
|
-
expect {
|
|
50
|
-
TestWorker.perform_in(Time.now + 901, 'message')
|
|
51
|
-
}.to raise_error 'The maximum allowed delay is 15 minutes'
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe '.perform_async' do
|
|
56
|
-
it 'enqueues a message' do
|
|
57
|
-
expect(sqs_queue).to receive(:send_message).with(
|
|
58
|
-
message_attributes: {
|
|
59
|
-
'shoryuken_class' => {
|
|
60
|
-
string_value: TestWorker.to_s,
|
|
61
|
-
data_type: 'String'
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
message_body: 'message')
|
|
65
|
-
|
|
66
|
-
TestWorker.perform_async('message')
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'enqueues a message with options' do
|
|
70
|
-
expect(sqs_queue).to receive(:send_message).with(
|
|
71
|
-
delay_seconds: 60,
|
|
72
|
-
message_attributes: {
|
|
73
|
-
'shoryuken_class' => {
|
|
74
|
-
string_value: TestWorker.to_s,
|
|
75
|
-
data_type: 'String'
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
message_body: 'delayed message')
|
|
79
|
-
|
|
80
|
-
TestWorker.perform_async('delayed message', delay_seconds: 60)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'accepts an `queue` option' do
|
|
84
|
-
new_queue = 'some_different_queue'
|
|
85
|
-
|
|
86
|
-
expect(Shoryuken::Client).to receive(:queues).with(new_queue).and_return(sqs_queue)
|
|
87
|
-
|
|
88
|
-
expect(sqs_queue).to receive(:send_message).with(
|
|
89
|
-
message_attributes: {
|
|
90
|
-
'shoryuken_class' => {
|
|
91
|
-
string_value: TestWorker.to_s,
|
|
92
|
-
data_type: 'String'
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
message_body: 'delayed message')
|
|
96
|
-
|
|
97
|
-
TestWorker.perform_async('delayed message', queue: new_queue)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
11
|
describe '.shoryuken_options' do
|
|
102
12
|
it 'registers a worker' do
|
|
103
13
|
expect(Shoryuken.worker_registry.workers('default')).to eq([TestWorker])
|
|
@@ -116,6 +26,20 @@ RSpec.describe 'Shoryuken::Worker' do
|
|
|
116
26
|
expect(NewTestWorker.get_shoryuken_options['queue']).to eq 'production_default'
|
|
117
27
|
end
|
|
118
28
|
|
|
29
|
+
it 'does not change the original hash' do
|
|
30
|
+
class TestWorker
|
|
31
|
+
include Shoryuken::Worker
|
|
32
|
+
|
|
33
|
+
OPT = { queue: :default }
|
|
34
|
+
|
|
35
|
+
shoryuken_options OPT
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
expect(TestWorker::OPT['queue']).to eq(nil)
|
|
39
|
+
expect(TestWorker.get_shoryuken_options['queue']).to eq('default')
|
|
40
|
+
expect(TestWorker::OPT[:queue]).to eq(:default)
|
|
41
|
+
end
|
|
42
|
+
|
|
119
43
|
it 'accepts an array as a queue' do
|
|
120
44
|
class WorkerMultipleQueues
|
|
121
45
|
include Shoryuken::Worker
|
|
@@ -164,6 +88,23 @@ RSpec.describe 'Shoryuken::Worker' do
|
|
|
164
88
|
expect(Shoryuken.worker_registry.workers('symbol_queue2')).to eq([WorkerMultipleSymbolQueues])
|
|
165
89
|
expect(Shoryuken.worker_registry.workers('symbol_queue3')).to eq([WorkerMultipleSymbolQueues])
|
|
166
90
|
end
|
|
91
|
+
|
|
92
|
+
it 'preserves parent class options' do
|
|
93
|
+
class ParentWorker
|
|
94
|
+
include Shoryuken::Worker
|
|
95
|
+
|
|
96
|
+
shoryuken_options queue: "myqueue", auto_delete: false
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class ChildWorker < ParentWorker
|
|
100
|
+
shoryuken_options auto_delete: true
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
expect(ParentWorker.get_shoryuken_options['queue']).to eq("myqueue")
|
|
104
|
+
expect(ChildWorker.get_shoryuken_options['queue']).to eq("myqueue")
|
|
105
|
+
expect(ParentWorker.get_shoryuken_options['auto_delete']).to eq(false)
|
|
106
|
+
expect(ChildWorker.get_shoryuken_options['auto_delete']).to eq(true)
|
|
107
|
+
end
|
|
167
108
|
end
|
|
168
109
|
|
|
169
110
|
describe '.server_middleware' do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -52,11 +52,16 @@ RSpec.configure do |config|
|
|
|
52
52
|
TestWorker.get_shoryuken_options.clear
|
|
53
53
|
TestWorker.get_shoryuken_options['queue'] = 'default'
|
|
54
54
|
|
|
55
|
+
Shoryuken.active_job_queue_name_prefixing = false
|
|
56
|
+
|
|
55
57
|
Shoryuken.worker_registry.clear
|
|
56
58
|
Shoryuken.register_worker('default', TestWorker)
|
|
57
59
|
|
|
58
60
|
Aws.config[:stub_responses] = true
|
|
59
61
|
|
|
62
|
+
Shoryuken.sqs_client_receive_message_opts.clear
|
|
63
|
+
|
|
60
64
|
allow(Concurrent).to receive(:global_io_executor).and_return(Concurrent::ImmediateExecutor.new)
|
|
65
|
+
allow(Shoryuken).to receive(:active_job?).and_return(false)
|
|
61
66
|
end
|
|
62
67
|
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: 3.
|
|
4
|
+
version: 3.2.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:
|
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -84,14 +84,14 @@ dependencies:
|
|
|
84
84
|
name: aws-sdk-core
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- - "
|
|
87
|
+
- - ">="
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: '2'
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- - "
|
|
94
|
+
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '2'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
@@ -137,6 +137,7 @@ files:
|
|
|
137
137
|
- ".travis.yml"
|
|
138
138
|
- CHANGELOG.md
|
|
139
139
|
- Gemfile
|
|
140
|
+
- Gemfile.aws-sdk-core-v2
|
|
140
141
|
- LICENSE
|
|
141
142
|
- README.md
|
|
142
143
|
- Rakefile
|
|
@@ -146,6 +147,7 @@ files:
|
|
|
146
147
|
- examples/bootstrap_queues.rb
|
|
147
148
|
- examples/default_worker.rb
|
|
148
149
|
- lib/shoryuken.rb
|
|
150
|
+
- lib/shoryuken/body_parser.rb
|
|
149
151
|
- lib/shoryuken/client.rb
|
|
150
152
|
- lib/shoryuken/core_ext.rb
|
|
151
153
|
- lib/shoryuken/default_worker_registry.rb
|
|
@@ -172,11 +174,14 @@ files:
|
|
|
172
174
|
- lib/shoryuken/util.rb
|
|
173
175
|
- lib/shoryuken/version.rb
|
|
174
176
|
- lib/shoryuken/worker.rb
|
|
177
|
+
- lib/shoryuken/worker/default_executor.rb
|
|
178
|
+
- lib/shoryuken/worker/inline_executor.rb
|
|
175
179
|
- lib/shoryuken/worker_registry.rb
|
|
176
180
|
- shoryuken.gemspec
|
|
177
181
|
- shoryuken.jpg
|
|
178
182
|
- spec/integration/launcher_spec.rb
|
|
179
183
|
- spec/shoryuken.yml
|
|
184
|
+
- spec/shoryuken/body_parser_spec.rb
|
|
180
185
|
- spec/shoryuken/client_spec.rb
|
|
181
186
|
- spec/shoryuken/core_ext_spec.rb
|
|
182
187
|
- spec/shoryuken/default_worker_registry_spec.rb
|
|
@@ -195,6 +200,8 @@ files:
|
|
|
195
200
|
- spec/shoryuken/queue_spec.rb
|
|
196
201
|
- spec/shoryuken/runner_spec.rb
|
|
197
202
|
- spec/shoryuken/util_spec.rb
|
|
203
|
+
- spec/shoryuken/worker/default_executor_spec.rb
|
|
204
|
+
- spec/shoryuken/worker/inline_executor_spec.rb
|
|
198
205
|
- spec/shoryuken/worker_spec.rb
|
|
199
206
|
- spec/shoryuken_spec.rb
|
|
200
207
|
- spec/spec_helper.rb
|
|
@@ -220,13 +227,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
220
227
|
version: '0'
|
|
221
228
|
requirements: []
|
|
222
229
|
rubyforge_project:
|
|
223
|
-
rubygems_version: 2.6.
|
|
230
|
+
rubygems_version: 2.6.13
|
|
224
231
|
signing_key:
|
|
225
232
|
specification_version: 4
|
|
226
233
|
summary: Shoryuken is a super efficient AWS SQS thread based message processor
|
|
227
234
|
test_files:
|
|
228
235
|
- spec/integration/launcher_spec.rb
|
|
229
236
|
- spec/shoryuken.yml
|
|
237
|
+
- spec/shoryuken/body_parser_spec.rb
|
|
230
238
|
- spec/shoryuken/client_spec.rb
|
|
231
239
|
- spec/shoryuken/core_ext_spec.rb
|
|
232
240
|
- spec/shoryuken/default_worker_registry_spec.rb
|
|
@@ -245,6 +253,8 @@ test_files:
|
|
|
245
253
|
- spec/shoryuken/queue_spec.rb
|
|
246
254
|
- spec/shoryuken/runner_spec.rb
|
|
247
255
|
- spec/shoryuken/util_spec.rb
|
|
256
|
+
- spec/shoryuken/worker/default_executor_spec.rb
|
|
257
|
+
- spec/shoryuken/worker/inline_executor_spec.rb
|
|
248
258
|
- spec/shoryuken/worker_spec.rb
|
|
249
259
|
- spec/shoryuken_spec.rb
|
|
250
260
|
- spec/spec_helper.rb
|