shoryuken 5.0.4 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9793af33c7faa6fed94f9ba3c4d195de11fbb2bac9147740cec68f3f0a9b60b0
4
- data.tar.gz: ba16095e67066c94e72fb9472d1f34d238bfbde6c1a77797f36c683426abb41e
3
+ metadata.gz: c2a0f01f40da91819e9e8e0b127a2504fccdd927365866f7971a7df207cea287
4
+ data.tar.gz: 3da85303fc49af5b0ad06888d667bde14ef12b79c595c98cdc3232d085d08350
5
5
  SHA512:
6
- metadata.gz: 80108514d02ec16533f76b172df6f5d350dcd1b3d4253bda633ebbc4fc84398e3d5073e8d47f155a2b9f42da69b008b1650f48c612759314807bc9e9d0488c2c
7
- data.tar.gz: de622970e9b943f26933934de1784d99c0f788607f7b9ae8d183601a55dba61b514d0d9b0813b09590de35bb74a985d62a5b891834a18f4319e6b740e62c9517
6
+ metadata.gz: 8a94cf02d3c7c25bf8282097449b83f1f4f3b4816b0e7be396048585ccc5667e9dcbdfe839f593c0ed04b2304fc1c0ca2d5d9564c86b854de63de6dafddc5de9
7
+ data.tar.gz: 20844e414f26d4a6a4e9d3db14bd4ea89bad4550486b91a1a1b8ba6eff2145e89fdf63007e356c707e54dbe8e0d1bb608844ec81db02516e84c4971633fd621d
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - '**/Gemfile'
4
- TargetRubyVersion: 2.3
4
+ TargetRubyVersion: 2.4
5
5
 
6
6
  Metrics/PerceivedComplexity:
7
7
  Enabled: false
@@ -1,10 +1,6 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.0.0
5
- - 2.1.10
6
- - 2.2.10
7
- - 2.3.8
8
4
  - 2.4.4
9
5
  - 2.5.1
10
6
  - 2.6.3
@@ -1,3 +1,8 @@
1
+ ## [v5.0.5] - 2020-06-07
2
+
3
+ - Add ability to configure queue by ARN
4
+ - [#603](https://github.com/phstc/shoryuken/pull/603)
5
+
1
6
  ## [v5.0.4] - 2020-02-20
2
7
 
3
8
  - Add endpoint option to SQS CLI
data/README.md CHANGED
@@ -21,7 +21,7 @@ Shoryuken _sho-ryu-ken_ is a super-efficient [Amazon SQS](https://aws.amazon.com
21
21
 
22
22
  ## Requirements
23
23
 
24
- Ruby 2.0 or greater.
24
+ Ruby 2.4 or greater.
25
25
 
26
26
  ## Installation
27
27
 
@@ -8,9 +8,9 @@ module Shoryuken
8
8
 
9
9
  attr_accessor :name, :client, :url
10
10
 
11
- def initialize(client, name_or_url)
11
+ def initialize(client, name_or_url_or_arn)
12
12
  self.client = client
13
- set_name_and_url(name_or_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 set_by_name(name)
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 set_name_and_url(name_or_url)
69
- if name_or_url.include?('://')
70
- set_by_url(name_or_url)
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
- return fifo?
100
+ initialize_fifo_attribute
101
+ return
74
102
  end
75
103
 
76
- set_by_name(name_or_url)
77
- rescue Aws::Errors::NoSuchEndpointError, Aws::SQS::Errors::NonExistentQueue => ex
78
- raise ex, "The specified queue #{name_or_url} does not exist."
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
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '5.0.4'.freeze
2
+ VERSION = '5.0.5'.freeze
3
3
  end
@@ -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
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-02-20 00:00:00.000000000 Z
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: '0'
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: '0'
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
- rubygems_version: 3.1.2
221
- signing_key:
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: