shoryuken 1.0.0 → 2.0.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 -0
- data/.hound.yml +6 -2
- data/.rubocop.yml +50 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +4 -1
- data/README.md +6 -52
- data/examples/bootstrap_queues.rb +1 -1
- data/lib/shoryuken/cli.rb +14 -14
- data/lib/shoryuken/client.rb +4 -7
- data/lib/shoryuken/default_worker_registry.rb +1 -1
- data/lib/shoryuken/environment_loader.rb +34 -16
- data/lib/shoryuken/extensions/active_job_adapter.rb +0 -1
- data/lib/shoryuken/fetcher.rb +8 -6
- data/lib/shoryuken/launcher.rb +1 -1
- data/lib/shoryuken/logging.rb +4 -6
- data/lib/shoryuken/manager.rb +13 -13
- data/lib/shoryuken/message.rb +70 -0
- data/lib/shoryuken/middleware/chain.rb +2 -2
- data/lib/shoryuken/middleware/server/exponential_backoff_retry.rb +50 -0
- data/lib/shoryuken/middleware/server/timing.rb +4 -4
- data/lib/shoryuken/processor.rb +28 -14
- data/lib/shoryuken/queue.rb +84 -0
- data/lib/shoryuken/sns_arn.rb +3 -3
- data/lib/shoryuken/util.rb +5 -6
- data/lib/shoryuken/version.rb +1 -1
- data/lib/shoryuken/worker.rb +1 -2
- data/lib/shoryuken.rb +29 -7
- data/shoryuken.gemspec +15 -16
- data/spec/shoryuken/client_spec.rb +45 -4
- data/spec/shoryuken/default_worker_registry_spec.rb +1 -1
- data/spec/shoryuken/fetcher_spec.rb +6 -6
- data/spec/shoryuken/middleware/chain_spec.rb +3 -1
- data/spec/shoryuken/middleware/server/auto_delete_spec.rb +2 -2
- data/spec/shoryuken/middleware/server/exponential_backoff_retry_spec.rb +77 -0
- data/spec/shoryuken/middleware/server/timing_spec.rb +23 -9
- data/spec/shoryuken/processor_spec.rb +39 -13
- data/spec/shoryuken/queue_spec.rb +100 -0
- data/spec/shoryuken/util_spec.rb +1 -1
- data/spec/shoryuken/worker_spec.rb +0 -13
- data/spec/shoryuken_endpoint.yml +6 -0
- data/spec/spec_helper.rb +4 -4
- metadata +36 -39
|
@@ -58,7 +58,9 @@ describe Shoryuken::Middleware::Chain do
|
|
|
58
58
|
it 'patches deprecated middleware' do
|
|
59
59
|
subject.clear
|
|
60
60
|
|
|
61
|
-
expect(Shoryuken.logger).to receive(:warn)
|
|
61
|
+
expect(Shoryuken.logger).to receive(:warn) do |&block|
|
|
62
|
+
expect(block.call).to eq('[DEPRECATION] DeprecatedMiddleware#call(worker_instance, queue, sqs_msg) is deprecated. Please use DeprecatedMiddleware#call(worker_instance, queue, sqs_msg, body)')
|
|
63
|
+
end
|
|
62
64
|
|
|
63
65
|
subject.add DeprecatedMiddleware
|
|
64
66
|
|
|
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe Shoryuken::Middleware::Server::AutoDelete do
|
|
4
4
|
let(:queue) { 'default' }
|
|
5
|
-
let(:sqs_queue) { double
|
|
5
|
+
let(:sqs_queue) { double Shoryuken::Queue }
|
|
6
6
|
|
|
7
7
|
def build_message
|
|
8
|
-
double
|
|
8
|
+
double Shoryuken::Message,
|
|
9
9
|
queue_url: queue,
|
|
10
10
|
body: 'test',
|
|
11
11
|
receipt_handle: SecureRandom.uuid
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoryuken::Middleware::Server::ExponentialBackoffRetry do
|
|
4
|
+
let(:queue) { 'default' }
|
|
5
|
+
let(:sqs_queue) { double Shoryuken::Queue }
|
|
6
|
+
let(:sqs_msg) { double Shoryuken::Message, queue_url: queue, body: 'test', receipt_handle: SecureRandom.uuid,
|
|
7
|
+
attributes: {'ApproximateReceiveCount' => 1}, message_id: SecureRandom.uuid }
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
allow(Shoryuken::Client).to receive(:queues).with(queue).and_return(sqs_queue)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context 'when a job succeeds' do
|
|
14
|
+
it 'does not retry the job' do
|
|
15
|
+
TestWorker.get_shoryuken_options['retry_intervals'] = [300, 1800]
|
|
16
|
+
|
|
17
|
+
expect(sqs_msg).not_to receive(:change_visibility)
|
|
18
|
+
|
|
19
|
+
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) {}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'when a job throws an exception' do
|
|
24
|
+
|
|
25
|
+
it 'does not retry the job by default' do
|
|
26
|
+
expect(sqs_msg).not_to receive(:change_visibility)
|
|
27
|
+
|
|
28
|
+
expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.to raise_error
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'does not retry the job if :retry_intervals is empty' do
|
|
32
|
+
TestWorker.get_shoryuken_options['retry_intervals'] = []
|
|
33
|
+
|
|
34
|
+
expect(sqs_msg).not_to receive(:change_visibility)
|
|
35
|
+
|
|
36
|
+
expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.to raise_error
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'retries the job if :retry_intervals is non-empty' do
|
|
40
|
+
TestWorker.get_shoryuken_options['retry_intervals'] = [300, 1800]
|
|
41
|
+
|
|
42
|
+
allow(sqs_msg).to receive(:queue){ sqs_queue }
|
|
43
|
+
expect(sqs_msg).to receive(:change_visibility).with(visibility_timeout: 300)
|
|
44
|
+
|
|
45
|
+
expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.not_to raise_error
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'retries the job with exponential backoff' do
|
|
49
|
+
TestWorker.get_shoryuken_options['retry_intervals'] = [300, 1800]
|
|
50
|
+
|
|
51
|
+
allow(sqs_msg).to receive(:attributes){ {'ApproximateReceiveCount' => 2 } }
|
|
52
|
+
allow(sqs_msg).to receive(:queue){ sqs_queue }
|
|
53
|
+
expect(sqs_msg).to receive(:change_visibility).with(visibility_timeout: 1800)
|
|
54
|
+
|
|
55
|
+
expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.not_to raise_error
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'uses the last retry interval when :receive_count exceeds the size of :retry_intervals' do
|
|
59
|
+
TestWorker.get_shoryuken_options['retry_intervals'] = [300, 1800]
|
|
60
|
+
|
|
61
|
+
allow(sqs_msg).to receive(:attributes){ {'ApproximateReceiveCount' => 3 } }
|
|
62
|
+
allow(sqs_msg).to receive(:queue){ sqs_queue }
|
|
63
|
+
expect(sqs_msg).to receive(:change_visibility).with(visibility_timeout: 1800)
|
|
64
|
+
|
|
65
|
+
expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.not_to raise_error
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'limits the visibility timeout to 12 hours from receipt of message' do
|
|
69
|
+
TestWorker.get_shoryuken_options['retry_intervals'] = [86400]
|
|
70
|
+
|
|
71
|
+
allow(sqs_msg).to receive(:queue){ sqs_queue }
|
|
72
|
+
expect(sqs_msg).to receive(:change_visibility).with(visibility_timeout: 43198)
|
|
73
|
+
|
|
74
|
+
expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.not_to raise_error
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe Shoryuken::Middleware::Server::Timing do
|
|
4
4
|
let(:queue) { 'default' }
|
|
5
|
-
let(:sqs_queue) { double
|
|
5
|
+
let(:sqs_queue) { double Shoryuken::Queue, visibility_timeout: 60 }
|
|
6
6
|
|
|
7
7
|
let(:sqs_msg) do
|
|
8
|
-
double
|
|
8
|
+
double Shoryuken::Message,
|
|
9
9
|
queue_url: queue,
|
|
10
10
|
body: 'test',
|
|
11
11
|
message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e'
|
|
@@ -16,8 +16,12 @@ describe Shoryuken::Middleware::Server::Timing do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it 'logs timing' do
|
|
19
|
-
expect(Shoryuken.logger).to receive(:info)
|
|
20
|
-
|
|
19
|
+
expect(Shoryuken.logger).to receive(:info) do |&block|
|
|
20
|
+
expect(block.call).to match(/started at/)
|
|
21
|
+
end
|
|
22
|
+
expect(Shoryuken.logger).to receive(:info) do |&block|
|
|
23
|
+
expect(block.call).to match(/completed in/)
|
|
24
|
+
end
|
|
21
25
|
|
|
22
26
|
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) {}
|
|
23
27
|
end
|
|
@@ -26,9 +30,15 @@ describe Shoryuken::Middleware::Server::Timing do
|
|
|
26
30
|
it 'logs exceeded' do
|
|
27
31
|
allow(subject).to receive(:elapsed).and_return(120000)
|
|
28
32
|
|
|
29
|
-
expect(Shoryuken.logger).to receive(:info)
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
expect(Shoryuken.logger).to receive(:info) do |&block|
|
|
34
|
+
expect(block.call).to match(/started at/)
|
|
35
|
+
end
|
|
36
|
+
expect(Shoryuken.logger).to receive(:info) do |&block|
|
|
37
|
+
expect(block.call).to match(/completed in/)
|
|
38
|
+
end
|
|
39
|
+
expect(Shoryuken.logger).to receive(:warn) do |&block|
|
|
40
|
+
expect(block.call).to match('exceeded the queue visibility timeout by 60000 ms')
|
|
41
|
+
end
|
|
32
42
|
|
|
33
43
|
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) {}
|
|
34
44
|
end
|
|
@@ -36,8 +46,12 @@ describe Shoryuken::Middleware::Server::Timing do
|
|
|
36
46
|
|
|
37
47
|
context 'when exception' do
|
|
38
48
|
it 'logs failed in' do
|
|
39
|
-
expect(Shoryuken.logger).to receive(:info)
|
|
40
|
-
|
|
49
|
+
expect(Shoryuken.logger).to receive(:info) do |&block|
|
|
50
|
+
expect(block.call).to match(/started at/)
|
|
51
|
+
end
|
|
52
|
+
expect(Shoryuken.logger).to receive(:info) do |&block|
|
|
53
|
+
expect(block.call).to match(/failed in/)
|
|
54
|
+
end
|
|
41
55
|
|
|
42
56
|
expect {
|
|
43
57
|
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise }
|
|
@@ -4,11 +4,11 @@ require 'shoryuken/manager'
|
|
|
4
4
|
|
|
5
5
|
describe Shoryuken::Processor do
|
|
6
6
|
let(:manager) { double Shoryuken::Manager, processor_done: nil }
|
|
7
|
-
let(:sqs_queue) { double
|
|
7
|
+
let(:sqs_queue) { double Shoryuken::Queue, visibility_timeout: 30 }
|
|
8
8
|
let(:queue) { 'default' }
|
|
9
9
|
|
|
10
10
|
let(:sqs_msg) do
|
|
11
|
-
double
|
|
11
|
+
double Shoryuken::Message,
|
|
12
12
|
queue_url: queue,
|
|
13
13
|
body: 'test',
|
|
14
14
|
message_attributes: {},
|
|
@@ -38,7 +38,7 @@ describe Shoryuken::Processor do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it 'parses the body calling the proc' do
|
|
41
|
-
TestWorker.get_shoryuken_options['body_parser'] =
|
|
41
|
+
TestWorker.get_shoryuken_options['body_parser'] = proc { |sqs_msg| "*#{sqs_msg.body}*" }
|
|
42
42
|
|
|
43
43
|
expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, '*test*')
|
|
44
44
|
|
|
@@ -59,8 +59,28 @@ describe Shoryuken::Processor do
|
|
|
59
59
|
subject.process(queue, sqs_msg)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
it 'parses calling `.load`' do
|
|
63
|
+
TestWorker.get_shoryuken_options['body_parser'] = Class.new do
|
|
64
|
+
def self.load(*args)
|
|
65
|
+
JSON.load(*args)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
body = { 'test' => 'hi' }
|
|
70
|
+
|
|
71
|
+
expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, body)
|
|
72
|
+
|
|
73
|
+
allow(sqs_msg).to receive(:body).and_return(JSON.dump(body))
|
|
74
|
+
|
|
75
|
+
subject.process(queue, sqs_msg)
|
|
76
|
+
end
|
|
77
|
+
|
|
62
78
|
it 'parses calling `.parse`' do
|
|
63
|
-
TestWorker.get_shoryuken_options['body_parser'] =
|
|
79
|
+
TestWorker.get_shoryuken_options['body_parser'] = Class.new do
|
|
80
|
+
def self.parse(*args)
|
|
81
|
+
JSON.parse(*args)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
64
84
|
|
|
65
85
|
body = { 'test' => 'hi' }
|
|
66
86
|
|
|
@@ -72,16 +92,22 @@ describe Shoryuken::Processor do
|
|
|
72
92
|
end
|
|
73
93
|
|
|
74
94
|
context 'when parse errors' do
|
|
75
|
-
|
|
95
|
+
before do
|
|
76
96
|
TestWorker.get_shoryuken_options['body_parser'] = :json
|
|
77
97
|
|
|
78
|
-
expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, nil)
|
|
79
|
-
|
|
80
98
|
allow(sqs_msg).to receive(:body).and_return('invalid json')
|
|
99
|
+
end
|
|
81
100
|
|
|
82
|
-
|
|
101
|
+
it 'logs the error' do
|
|
102
|
+
expect(subject.logger).to receive(:error) do |&block|
|
|
103
|
+
expect(block.call).to eq("Error parsing the message body: 757: unexpected token at 'invalid json'\nbody_parser: json\nsqs_msg.body: invalid json")
|
|
104
|
+
end
|
|
83
105
|
|
|
84
|
-
subject.process(queue, sqs_msg)
|
|
106
|
+
subject.process(queue, sqs_msg) rescue nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 're raises the error' do
|
|
110
|
+
expect{ subject.process(queue, sqs_msg) }.to raise_error(JSON::ParserError, "757: unexpected token at 'invalid json'")
|
|
85
111
|
end
|
|
86
112
|
end
|
|
87
113
|
|
|
@@ -207,15 +233,15 @@ describe Shoryuken::Processor do
|
|
|
207
233
|
|
|
208
234
|
context 'when shoryuken_class header' do
|
|
209
235
|
let(:sqs_msg) do
|
|
210
|
-
double
|
|
236
|
+
double Shoryuken::Message,
|
|
211
237
|
queue_url: queue,
|
|
212
238
|
body: 'test',
|
|
213
239
|
message_attributes: {
|
|
214
240
|
'shoryuken_class' => {
|
|
215
241
|
string_value: TestWorker.to_s,
|
|
216
242
|
data_type: 'String' }},
|
|
217
|
-
|
|
218
|
-
|
|
243
|
+
message_id: SecureRandom.uuid,
|
|
244
|
+
receipt_handle: SecureRandom.uuid
|
|
219
245
|
end
|
|
220
246
|
|
|
221
247
|
it 'performs without delete' do
|
|
@@ -244,7 +270,7 @@ describe Shoryuken::Processor do
|
|
|
244
270
|
|
|
245
271
|
context 'when the worker takes a long time', slow: true do
|
|
246
272
|
it 'extends the message invisibility to prevent it from being dequeued concurrently' do
|
|
247
|
-
TestWorker.get_shoryuken_options['body_parser'] =
|
|
273
|
+
TestWorker.get_shoryuken_options['body_parser'] = proc do
|
|
248
274
|
sleep visibility_timeout
|
|
249
275
|
'test'
|
|
250
276
|
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Shoryuken::Queue do
|
|
4
|
+
let(:credentials) { Aws::Credentials.new('access_key_id', 'secret_access_key') }
|
|
5
|
+
let(:sqs) { Aws::SQS::Client.new(stub_responses: true, credentials: credentials) }
|
|
6
|
+
let(:queue_name) { 'shoryuken' }
|
|
7
|
+
let(:queue_url) { 'https://eu-west-1.amazonaws.com:6059/123456789012/shoryuken' }
|
|
8
|
+
|
|
9
|
+
subject { described_class.new(sqs, queue_name) }
|
|
10
|
+
|
|
11
|
+
describe '#send_message' do
|
|
12
|
+
it 'accepts SQS request parameters' do
|
|
13
|
+
# https://docs.aws.amazon.com/sdkforruby/api/Aws/SQS/Client.html#send_message-instance_method
|
|
14
|
+
expect(sqs).to receive(:send_message).with(hash_including(message_body: 'msg1'))
|
|
15
|
+
|
|
16
|
+
subject.send_message(message_body: 'msg1')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'accepts a string' do
|
|
20
|
+
expect(sqs).to receive(:send_message).with(hash_including(message_body: 'msg1'))
|
|
21
|
+
|
|
22
|
+
subject.send_message('msg1')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'when body is invalid' do
|
|
26
|
+
it 'raises ArgumentError for nil' do
|
|
27
|
+
expect {
|
|
28
|
+
subject.send_message(message_body: nil)
|
|
29
|
+
}.to raise_error(ArgumentError, 'The message body must be a String and you passed a NilClass')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'raises ArgumentError for Fixnum' do
|
|
33
|
+
expect {
|
|
34
|
+
subject.send_message(message_body: 1)
|
|
35
|
+
}.to raise_error(ArgumentError, 'The message body must be a String and you passed a Fixnum')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'when a client middleware' do
|
|
39
|
+
class MyClientMiddleware
|
|
40
|
+
def call(options)
|
|
41
|
+
options[:message_body] = 'changed'
|
|
42
|
+
|
|
43
|
+
yield
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
Shoryuken.configure_client do |config|
|
|
49
|
+
config.client_middleware do |chain|
|
|
50
|
+
chain.add MyClientMiddleware
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
after do
|
|
56
|
+
Shoryuken.configure_client do |config|
|
|
57
|
+
config.client_middleware do |chain|
|
|
58
|
+
chain.remove MyClientMiddleware
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'invokes MyClientMiddleware' do
|
|
64
|
+
expect(sqs).to receive(:send_message).with(hash_including(message_body: 'changed'))
|
|
65
|
+
|
|
66
|
+
subject.send_message(message_body: 'original')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe '#send_messages' do
|
|
73
|
+
it 'accepts SQS request parameters' do
|
|
74
|
+
# https://docs.aws.amazon.com/sdkforruby/api/Aws/SQS/Client.html#send_message_batch-instance_method
|
|
75
|
+
expect(sqs).to receive(:send_message_batch).with(hash_including(entries: [{ id: '0', message_body: 'msg1'}, { id: '1', message_body: 'msg2' }]))
|
|
76
|
+
|
|
77
|
+
subject.send_messages(entries: [{ id: '0', message_body: 'msg1'}, { id: '1', message_body: 'msg2' }])
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'accepts an array of string' do
|
|
81
|
+
expect(sqs).to receive(:send_message_batch).with(hash_including(entries: [{ id: '0', message_body: 'msg1'}, { id: '1', message_body: 'msg2' }]))
|
|
82
|
+
|
|
83
|
+
subject.send_messages(%w(msg1 msg2))
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'when body is invalid' do
|
|
87
|
+
it 'raises ArgumentError for nil' do
|
|
88
|
+
expect {
|
|
89
|
+
subject.send_messages(entries: [message_body: nil])
|
|
90
|
+
}.to raise_error(ArgumentError, 'The message body must be a String and you passed a NilClass')
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'raises ArgumentError for Fixnum' do
|
|
94
|
+
expect {
|
|
95
|
+
subject.send_messages(entries: [message_body: 1])
|
|
96
|
+
}.to raise_error(ArgumentError, 'The message body must be a String and you passed a Fixnum')
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
data/spec/shoryuken/util_spec.rb
CHANGED
|
@@ -17,7 +17,7 @@ describe 'Shoryuken::Util' do
|
|
|
17
17
|
|
|
18
18
|
describe '#worker_name' do
|
|
19
19
|
let(:sqs_msg) do
|
|
20
|
-
double
|
|
20
|
+
double Shoryuken::Message, message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', message_attributes: {}
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'returns Shoryuken worker name' do
|
|
@@ -66,19 +66,6 @@ describe 'Shoryuken::Worker' do
|
|
|
66
66
|
TestWorker.perform_async('message')
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
it 'enqueues a message given as hash' do
|
|
70
|
-
expect(sqs_queue).to receive(:send_message).with(
|
|
71
|
-
message_attributes: {
|
|
72
|
-
'shoryuken_class' => {
|
|
73
|
-
string_value: TestWorker.to_s,
|
|
74
|
-
data_type: 'String'
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
message_body: '{"field":"part1","other_field":"part2"}')
|
|
78
|
-
|
|
79
|
-
TestWorker.perform_async(field: 'part1', other_field: 'part2')
|
|
80
|
-
end
|
|
81
|
-
|
|
82
69
|
it 'enqueues a message with options' do
|
|
83
70
|
expect(sqs_queue).to receive(:send_message).with(
|
|
84
71
|
delay_seconds: 60,
|
data/spec/spec_helper.rb
CHANGED
|
@@ -39,12 +39,12 @@ class TestWorker
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
RSpec.configure do |config|
|
|
42
|
-
|
|
42
|
+
# Only run slow tests if SPEC_ALL=true and AWS_ACCESS_KEY_ID is present
|
|
43
|
+
# The AWS_ACCESS_KEY_ID checker is because Travis CI does not expose ENV variables to pull requests from forked repositories
|
|
44
|
+
# http://docs.travis-ci.com/user/pull-requests/
|
|
45
|
+
config.filter_run_excluding slow: true if ENV['SPEC_ALL'] != 'true' || ENV['AWS_ACCESS_KEY_ID'].nil?
|
|
43
46
|
|
|
44
47
|
config.before do
|
|
45
|
-
# remove doubles, preventing:
|
|
46
|
-
# Double "Queue" was originally created in one example but has leaked into another example and can no longer be used.
|
|
47
|
-
# rspec-mocks' doubles are designed to only last for one example, and you need to create a new one in each example you wish to use it for.
|
|
48
48
|
Shoryuken::Client.class_variable_set :@@queues, {}
|
|
49
49
|
Shoryuken::Client.class_variable_set :@@visibility_timeouts, {}
|
|
50
50
|
|
metadata
CHANGED
|
@@ -1,139 +1,125 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shoryuken
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.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: 2015-
|
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.6'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.6'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: pry-byebug
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: nokogiri
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: dotenv
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- -
|
|
87
|
+
- - ">="
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: '0'
|
|
90
90
|
type: :development
|
|
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: '0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: aws-sdk-core
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
|
-
- -
|
|
101
|
+
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: 2.0.21
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
|
-
- -
|
|
108
|
+
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: 2.0.21
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: aws-sdk-resources
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - '='
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: 2.0.21.pre
|
|
118
|
-
type: :runtime
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - '='
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: 2.0.21.pre
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
112
|
name: celluloid
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
128
114
|
requirements:
|
|
129
|
-
- - ~>
|
|
115
|
+
- - "~>"
|
|
130
116
|
- !ruby/object:Gem::Version
|
|
131
117
|
version: 0.16.0
|
|
132
118
|
type: :runtime
|
|
133
119
|
prerelease: false
|
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
121
|
requirements:
|
|
136
|
-
- - ~>
|
|
122
|
+
- - "~>"
|
|
137
123
|
- !ruby/object:Gem::Version
|
|
138
124
|
version: 0.16.0
|
|
139
125
|
description: Shoryuken is a super efficient AWS SQS thread based message processor
|
|
@@ -144,10 +130,12 @@ executables:
|
|
|
144
130
|
extensions: []
|
|
145
131
|
extra_rdoc_files: []
|
|
146
132
|
files:
|
|
147
|
-
- .gitignore
|
|
148
|
-
- .hound.yml
|
|
149
|
-
- .rspec
|
|
150
|
-
- .
|
|
133
|
+
- ".gitignore"
|
|
134
|
+
- ".hound.yml"
|
|
135
|
+
- ".rspec"
|
|
136
|
+
- ".rubocop.yml"
|
|
137
|
+
- ".travis.yml"
|
|
138
|
+
- CHANGELOG.md
|
|
151
139
|
- Gemfile
|
|
152
140
|
- LICENSE.txt
|
|
153
141
|
- README.md
|
|
@@ -166,11 +154,14 @@ files:
|
|
|
166
154
|
- lib/shoryuken/launcher.rb
|
|
167
155
|
- lib/shoryuken/logging.rb
|
|
168
156
|
- lib/shoryuken/manager.rb
|
|
157
|
+
- lib/shoryuken/message.rb
|
|
169
158
|
- lib/shoryuken/middleware/chain.rb
|
|
170
159
|
- lib/shoryuken/middleware/server/active_record.rb
|
|
171
160
|
- lib/shoryuken/middleware/server/auto_delete.rb
|
|
161
|
+
- lib/shoryuken/middleware/server/exponential_backoff_retry.rb
|
|
172
162
|
- lib/shoryuken/middleware/server/timing.rb
|
|
173
163
|
- lib/shoryuken/processor.rb
|
|
164
|
+
- lib/shoryuken/queue.rb
|
|
174
165
|
- lib/shoryuken/sns_arn.rb
|
|
175
166
|
- lib/shoryuken/topic.rb
|
|
176
167
|
- lib/shoryuken/util.rb
|
|
@@ -188,12 +179,15 @@ files:
|
|
|
188
179
|
- spec/shoryuken/manager_spec.rb
|
|
189
180
|
- spec/shoryuken/middleware/chain_spec.rb
|
|
190
181
|
- spec/shoryuken/middleware/server/auto_delete_spec.rb
|
|
182
|
+
- spec/shoryuken/middleware/server/exponential_backoff_retry_spec.rb
|
|
191
183
|
- spec/shoryuken/middleware/server/timing_spec.rb
|
|
192
184
|
- spec/shoryuken/processor_spec.rb
|
|
185
|
+
- spec/shoryuken/queue_spec.rb
|
|
193
186
|
- spec/shoryuken/sns_arn_spec.rb
|
|
194
187
|
- spec/shoryuken/topic_spec.rb
|
|
195
188
|
- spec/shoryuken/util_spec.rb
|
|
196
189
|
- spec/shoryuken/worker_spec.rb
|
|
190
|
+
- spec/shoryuken_endpoint.yml
|
|
197
191
|
- spec/shoryuken_spec.rb
|
|
198
192
|
- spec/spec_helper.rb
|
|
199
193
|
homepage: https://github.com/phstc/shoryuken
|
|
@@ -206,17 +200,17 @@ require_paths:
|
|
|
206
200
|
- lib
|
|
207
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
202
|
requirements:
|
|
209
|
-
- -
|
|
203
|
+
- - ">="
|
|
210
204
|
- !ruby/object:Gem::Version
|
|
211
205
|
version: '0'
|
|
212
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
207
|
requirements:
|
|
214
|
-
- -
|
|
208
|
+
- - ">="
|
|
215
209
|
- !ruby/object:Gem::Version
|
|
216
210
|
version: '0'
|
|
217
211
|
requirements: []
|
|
218
212
|
rubyforge_project:
|
|
219
|
-
rubygems_version: 2.
|
|
213
|
+
rubygems_version: 2.2.5
|
|
220
214
|
signing_key:
|
|
221
215
|
specification_version: 4
|
|
222
216
|
summary: Shoryuken is a super efficient AWS SQS thread based message processor
|
|
@@ -230,11 +224,14 @@ test_files:
|
|
|
230
224
|
- spec/shoryuken/manager_spec.rb
|
|
231
225
|
- spec/shoryuken/middleware/chain_spec.rb
|
|
232
226
|
- spec/shoryuken/middleware/server/auto_delete_spec.rb
|
|
227
|
+
- spec/shoryuken/middleware/server/exponential_backoff_retry_spec.rb
|
|
233
228
|
- spec/shoryuken/middleware/server/timing_spec.rb
|
|
234
229
|
- spec/shoryuken/processor_spec.rb
|
|
230
|
+
- spec/shoryuken/queue_spec.rb
|
|
235
231
|
- spec/shoryuken/sns_arn_spec.rb
|
|
236
232
|
- spec/shoryuken/topic_spec.rb
|
|
237
233
|
- spec/shoryuken/util_spec.rb
|
|
238
234
|
- spec/shoryuken/worker_spec.rb
|
|
235
|
+
- spec/shoryuken_endpoint.yml
|
|
239
236
|
- spec/shoryuken_spec.rb
|
|
240
237
|
- spec/spec_helper.rb
|