shoryuken 4.0.0 → 4.0.1
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/shoryuken.rb +3 -1
- data/lib/shoryuken/options.rb +9 -0
- data/lib/shoryuken/queue.rb +4 -1
- data/lib/shoryuken/version.rb +1 -1
- data/lib/shoryuken/worker/inline_executor.rb +4 -2
- data/spec/shoryuken/queue_spec.rb +37 -0
- data/spec/spec_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f28614380213b13c17dea0f85aae332f8e335f6
|
4
|
+
data.tar.gz: 34e084982c8aa8ec9b0306f04f548cc1321eec13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a160284600447798e3e1ebc61ec1e8bf596b0aa9d5558301d7f647e1ab1af285b845a9ec052eb52e157714d4066d3888f6f2192762898d9fc52decf1503a3b
|
7
|
+
data.tar.gz: 7f3d7584167804ad724dc3ca3a661cef8a4a60cadccebe333ceacb10333c0eb1bc7db9247439ddce875a1b7cb771769e9516afcda0ae5703991db780acd165d3
|
data/.rubocop.yml
CHANGED
@@ -32,7 +32,7 @@ Style/Alias:
|
|
32
32
|
Style/PerlBackrefs:
|
33
33
|
Enabled: false
|
34
34
|
|
35
|
-
|
35
|
+
Layout/TrailingBlankLines:
|
36
36
|
Enabled: false
|
37
37
|
|
38
38
|
# Override the HoundCI custom rules (they do not use Rubocop defaults)
|
@@ -42,7 +42,7 @@ Style/StringLiterals:
|
|
42
42
|
Style/StringLiteralsInInterpolation:
|
43
43
|
EnforcedStyle: single_quotes
|
44
44
|
|
45
|
-
|
45
|
+
Layout/ExtraSpacing:
|
46
46
|
# disabling that in favour of using:
|
47
47
|
# long_field_test_1 = 1
|
48
48
|
# field_test_2 = 2
|
@@ -67,7 +67,7 @@ Style/ClassAndModuleChildren:
|
|
67
67
|
Style/CommentAnnotation:
|
68
68
|
Enabled: false
|
69
69
|
|
70
|
-
|
70
|
+
Layout/DotPosition:
|
71
71
|
EnforcedStyle: leading
|
72
72
|
|
73
73
|
Style/GuardClause:
|
@@ -103,7 +103,7 @@ Style/RescueModifier:
|
|
103
103
|
Style/ColonMethodCall:
|
104
104
|
Enabled: false
|
105
105
|
|
106
|
-
|
106
|
+
Naming/FileName:
|
107
107
|
Enabled: false
|
108
108
|
|
109
109
|
Style/FrozenStringLiteralComment:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [v4.0.1] - 2018-11-21
|
2
|
+
|
3
|
+
- Allow caching visibility_timeout lookups
|
4
|
+
- [#533](https://github.com/phstc/shoryuken/pull/533)
|
5
|
+
|
6
|
+
- Add queue name to inline executor
|
7
|
+
- [#532](https://github.com/phstc/shoryuken/pull/532)
|
8
|
+
|
1
9
|
## [v4.0.0] - 2018-11-01
|
2
10
|
|
3
11
|
- Process messages to the same message group ID one by one
|
data/lib/shoryuken.rb
CHANGED
data/lib/shoryuken/options.rb
CHANGED
@@ -23,6 +23,7 @@ module Shoryuken
|
|
23
23
|
@@stop_callback = nil
|
24
24
|
@@worker_executor = Worker::DefaultExecutor
|
25
25
|
@@launcher_executor = nil
|
26
|
+
@@cache_visiblity_timeout = false
|
26
27
|
|
27
28
|
class << self
|
28
29
|
def active_job?
|
@@ -220,6 +221,14 @@ module Shoryuken
|
|
220
221
|
def server?
|
221
222
|
defined?(Shoryuken::CLI)
|
222
223
|
end
|
224
|
+
|
225
|
+
def cache_visiblity_timeout?
|
226
|
+
@@cache_visiblity_timeout
|
227
|
+
end
|
228
|
+
|
229
|
+
def cache_visiblity_timeout=(cache_visiblity_timeout)
|
230
|
+
@@cache_visiblity_timeout = cache_visiblity_timeout
|
231
|
+
end
|
223
232
|
end
|
224
233
|
end
|
225
234
|
end
|
data/lib/shoryuken/queue.rb
CHANGED
@@ -14,7 +14,10 @@ module Shoryuken
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def visibility_timeout
|
17
|
-
|
17
|
+
# Always lookup for the latest visiblity when cache is disabled
|
18
|
+
# setting it to nil, forces re-lookup
|
19
|
+
@_visibility_timeout = nil unless Shoryuken.cache_visiblity_timeout?
|
20
|
+
@_visibility_timeout ||= queue_attributes.attributes[VISIBILITY_TIMEOUT_ATTR].to_i
|
18
21
|
end
|
19
22
|
|
20
23
|
def delete_messages(options)
|
data/lib/shoryuken/version.rb
CHANGED
@@ -2,8 +2,9 @@ module Shoryuken
|
|
2
2
|
module Worker
|
3
3
|
class InlineExecutor
|
4
4
|
class << self
|
5
|
-
def perform_async(worker_class, body,
|
5
|
+
def perform_async(worker_class, body, options = {})
|
6
6
|
body = JSON.dump(body) if body.is_a?(Hash)
|
7
|
+
queue_name = options.delete(:queue) || worker_class.get_shoryuken_options['queue']
|
7
8
|
|
8
9
|
sqs_msg = OpenStruct.new(
|
9
10
|
body: body,
|
@@ -13,7 +14,8 @@ module Shoryuken
|
|
13
14
|
message_attributes: nil,
|
14
15
|
message_id: nil,
|
15
16
|
receipt_handle: nil,
|
16
|
-
delete: nil
|
17
|
+
delete: nil,
|
18
|
+
queue_name: queue_name
|
17
19
|
)
|
18
20
|
|
19
21
|
call(worker_class, sqs_msg)
|
@@ -234,4 +234,41 @@ RSpec.describe Shoryuken::Queue do
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
end
|
237
|
+
|
238
|
+
describe '#visiblity_timeout' do
|
239
|
+
let(:attribute_response) { double 'Aws::SQS::Types::GetQueueAttributesResponse' }
|
240
|
+
|
241
|
+
before do
|
242
|
+
allow(attribute_response).to(
|
243
|
+
receive(:attributes).and_return('VisibilityTimeout' => 30)
|
244
|
+
)
|
245
|
+
allow(subject).to receive(:url).and_return(queue_url)
|
246
|
+
end
|
247
|
+
|
248
|
+
context 'when cache is disabled' do
|
249
|
+
specify do
|
250
|
+
Shoryuken.cache_visiblity_timeout = false
|
251
|
+
|
252
|
+
expect(sqs).to(
|
253
|
+
receive(:get_queue_attributes).with(queue_url: queue_url, attribute_names: ['All']).and_return(attribute_response).exactly(3).times
|
254
|
+
)
|
255
|
+
expect(subject.visibility_timeout).to eq(30)
|
256
|
+
expect(subject.visibility_timeout).to eq(30)
|
257
|
+
expect(subject.visibility_timeout).to eq(30)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
context 'when cache is enabled' do
|
262
|
+
it 'memoizes response' do
|
263
|
+
Shoryuken.cache_visiblity_timeout = true
|
264
|
+
|
265
|
+
expect(sqs).to(
|
266
|
+
receive(:get_queue_attributes).with(queue_url: queue_url, attribute_names: ['All']).and_return(attribute_response).once
|
267
|
+
)
|
268
|
+
expect(subject.visibility_timeout).to eq(30)
|
269
|
+
expect(subject.visibility_timeout).to eq(30)
|
270
|
+
expect(subject.visibility_timeout).to eq(30)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
237
274
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -61,6 +61,8 @@ RSpec.configure do |config|
|
|
61
61
|
|
62
62
|
Shoryuken.sqs_client_receive_message_opts.clear
|
63
63
|
|
64
|
+
Shoryuken.cache_visiblity_timeout = false
|
65
|
+
|
64
66
|
allow(Concurrent).to receive(:global_io_executor).and_return(Concurrent::ImmediateExecutor.new)
|
65
67
|
allow(Shoryuken).to receive(:active_job?).and_return(false)
|
66
68
|
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: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Cantero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|