shoryuken 5.0.4 → 5.0.5
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 +0 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/shoryuken/queue.rb +39 -11
- data/lib/shoryuken/version.rb +1 -1
- data/shoryuken.gemspec +1 -1
- data/spec/shoryuken/queue_spec.rb +23 -0
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2a0f01f40da91819e9e8e0b127a2504fccdd927365866f7971a7df207cea287
|
4
|
+
data.tar.gz: 3da85303fc49af5b0ad06888d667bde14ef12b79c595c98cdc3232d085d08350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a94cf02d3c7c25bf8282097449b83f1f4f3b4816b0e7be396048585ccc5667e9dcbdfe839f593c0ed04b2304fc1c0ca2d5d9564c86b854de63de6dafddc5de9
|
7
|
+
data.tar.gz: 20844e414f26d4a6a4e9d3db14bd4ea89bad4550486b91a1a1b8ba6eff2145e89fdf63007e356c707e54dbe8e0d1bb608844ec81db02516e84c4971633fd621d
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/shoryuken/queue.rb
CHANGED
@@ -8,9 +8,9 @@ module Shoryuken
|
|
8
8
|
|
9
9
|
attr_accessor :name, :client, :url
|
10
10
|
|
11
|
-
def initialize(client,
|
11
|
+
def initialize(client, name_or_url_or_arn)
|
12
12
|
self.client = client
|
13
|
-
set_name_and_url(
|
13
|
+
set_name_and_url(name_or_url_or_arn)
|
14
14
|
end
|
15
15
|
|
16
16
|
def visibility_timeout
|
@@ -50,32 +50,60 @@ module Shoryuken
|
|
50
50
|
# Make sure the memoization work with boolean to avoid multiple calls to SQS
|
51
51
|
# see https://github.com/phstc/shoryuken/pull/529
|
52
52
|
return @_fifo if defined?(@_fifo)
|
53
|
+
|
53
54
|
@_fifo = queue_attributes.attributes[FIFO_ATTR] == 'true'
|
55
|
+
@_fifo
|
54
56
|
end
|
55
57
|
|
56
58
|
private
|
57
59
|
|
58
|
-
def
|
60
|
+
def initialize_fifo_attribute
|
61
|
+
# calling fifo? will also initialize it
|
62
|
+
fifo?
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_by_name(name) # rubocop:disable Naming/AccessorMethodName
|
59
66
|
self.name = name
|
60
67
|
self.url = client.get_queue_url(queue_name: name).queue_url
|
61
68
|
end
|
62
69
|
|
63
|
-
def set_by_url(url)
|
70
|
+
def set_by_url(url) # rubocop:disable Naming/AccessorMethodName
|
64
71
|
self.name = url.split('/').last
|
65
72
|
self.url = url
|
66
73
|
end
|
67
74
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
75
|
+
def arn_to_url(arn_str)
|
76
|
+
*, region, account_id, resource = arn_str.split(':')
|
77
|
+
|
78
|
+
required = [region, account_id, resource].map(&:to_s)
|
79
|
+
valid = required.none?(&:empty?)
|
80
|
+
|
81
|
+
abort "Invalid ARN: #{arn_str}. A valid ARN must include: region, account_id and resource." unless valid
|
82
|
+
|
83
|
+
"https://sqs.#{region}.amazonaws.com/#{account_id}/#{resource}"
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_name_and_url(name_or_url_or_arn) # rubocop:disable Naming/AccessorMethodName
|
87
|
+
if name_or_url_or_arn.include?('://')
|
88
|
+
set_by_url(name_or_url_or_arn)
|
89
|
+
|
90
|
+
# anticipate the fifo? checker for validating the queue URL
|
91
|
+
initialize_fifo_attribute
|
92
|
+
return
|
93
|
+
end
|
94
|
+
|
95
|
+
if name_or_url_or_arn.start_with?('arn:')
|
96
|
+
url = arn_to_url(name_or_url_or_arn)
|
97
|
+
set_by_url(url)
|
71
98
|
|
72
99
|
# anticipate the fifo? checker for validating the queue URL
|
73
|
-
|
100
|
+
initialize_fifo_attribute
|
101
|
+
return
|
74
102
|
end
|
75
103
|
|
76
|
-
set_by_name(
|
77
|
-
rescue Aws::Errors::NoSuchEndpointError, Aws::SQS::Errors::NonExistentQueue =>
|
78
|
-
raise
|
104
|
+
set_by_name(name_or_url_or_arn)
|
105
|
+
rescue Aws::Errors::NoSuchEndpointError, Aws::SQS::Errors::NonExistentQueue => e
|
106
|
+
raise e, "The specified queue #{name_or_url_or_arn} does not exist."
|
79
107
|
end
|
80
108
|
|
81
109
|
def queue_attributes
|
data/lib/shoryuken/version.rb
CHANGED
data/shoryuken.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_development_dependency 'dotenv'
|
21
|
-
spec.add_development_dependency 'pry-byebug'
|
21
|
+
spec.add_development_dependency 'pry-byebug', '3.9.0'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
|
@@ -39,6 +39,29 @@ RSpec.describe Shoryuken::Queue do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
context 'when queue ARN supplied' do
|
43
|
+
let(:queue_arn) { 'arn:aws:sqs:ap-southeast-2:000000000000:queue-name' }
|
44
|
+
|
45
|
+
it 'initializes by URL and validate the URL' do
|
46
|
+
subject = described_class.new(sqs, queue_arn)
|
47
|
+
|
48
|
+
expect(subject.name).to eq('queue-name')
|
49
|
+
expect(subject.url).to eq('https://sqs.ap-southeast-2.amazonaws.com/000000000000/queue-name')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when invalid queue ARN supplied' do
|
54
|
+
let(:queue_arn) { 'arn:aws:sqs::000000000000:queue-name' }
|
55
|
+
|
56
|
+
it 'raises an error' do
|
57
|
+
expect do
|
58
|
+
described_class.new(sqs, queue_arn)
|
59
|
+
end.to raise_error(
|
60
|
+
'Invalid ARN: arn:aws:sqs::000000000000:queue-name. A valid ARN must include: region, account_id and resource.'
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
42
65
|
context 'when queue name supplied' do
|
43
66
|
subject { described_class.new(sqs, queue_name) }
|
44
67
|
|
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: 5.0.
|
4
|
+
version: 5.0.5
|
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: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: pry-byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.9.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
|
-
version:
|
40
|
+
version: 3.9.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,7 +202,7 @@ homepage: https://github.com/phstc/shoryuken
|
|
202
202
|
licenses:
|
203
203
|
- LGPL-3.0
|
204
204
|
metadata: {}
|
205
|
-
post_install_message:
|
205
|
+
post_install_message:
|
206
206
|
rdoc_options: []
|
207
207
|
require_paths:
|
208
208
|
- lib
|
@@ -217,8 +217,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
|
-
|
221
|
-
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.7.6.2
|
222
|
+
signing_key:
|
222
223
|
specification_version: 4
|
223
224
|
summary: Shoryuken is a super efficient AWS SQS thread based message processor
|
224
225
|
test_files:
|