shoryuken 3.0.8 → 3.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3748f41972ac2a8c233278b33432cb5c2056848a
4
- data.tar.gz: fa952b333c483077908c53bd0515c49026fd4d33
3
+ metadata.gz: c88cb34dfa2eae0fbeea81ff493f88c389232edb
4
+ data.tar.gz: b271d7d9015868d1d5b344d4f338c3e603e57b50
5
5
  SHA512:
6
- metadata.gz: 9cd990370ec8fc9da9f46400e98076eeea77c0dd4cb9ae1c291319ba0ed496ea9c536f6cdcb91757853f05c68a3e71d7f681a7838a077746a932d5b0c7a7560c
7
- data.tar.gz: 3dc1ac1e696112e865bc69fce0bc3eef745658de4627199f830fde4ac4d2351c2792629d51210d7bd92026b61dfe72b715073a14d5f3c9b7da93e87cf2486520
6
+ metadata.gz: 2a7a0ba02ee69d37ee8df087c9c260443cdb9559a48bd1bb58ea93e7c0281a8863acf9e91818b41ce91c211e3569d94fb88cf925ffbad579ccfa33dc917eb431
7
+ data.tar.gz: dbb15a8ff723305b3db21c01fa74eca91e9f782c07e5d65440eb71a3141969fd9a6bd38d0fe09b15f96260f7580b127c5ba78121f0444b5027ea011464793049
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [v3.0.9] - 2017-06-05
2
+
3
+ - Allow configuring queue URLs instead of names
4
+ - [#378](https://github.com/phstc/shoryuken/pull/378)
5
+
1
6
  ## [v3.0.8] - 2017-06-02
2
7
 
3
8
  - Fix miss handling empty batch fetches
@@ -119,7 +119,7 @@ module Shoryuken
119
119
  end
120
120
 
121
121
  def validate_queues
122
- Shoryuken.logger.warn { 'No queues supplied' } if Shoryuken.queues.empty?
122
+ return Shoryuken.logger.warn { 'No queues supplied' } if Shoryuken.queues.empty?
123
123
 
124
124
  non_existent_queues = []
125
125
 
@@ -131,7 +131,7 @@ module Shoryuken
131
131
  end
132
132
  end
133
133
 
134
- fail ArgumentError, "The specified queue(s) #{non_existent_queues} do not exist" if non_existent_queues.any?
134
+ fail ArgumentError, "The specified queue(s) #{non_existent_queues.join(', ')} do not exist" if non_existent_queues.any?
135
135
  end
136
136
 
137
137
  def validate_workers
@@ -8,12 +8,9 @@ module Shoryuken
8
8
 
9
9
  attr_accessor :name, :client, :url
10
10
 
11
- def initialize(client, name)
12
- self.name = name
11
+ def initialize(client, name_or_url)
13
12
  self.client = client
14
- self.url = client.get_queue_url(queue_name: name).queue_url
15
- rescue Aws::SQS::Errors::NonExistentQueue => ex
16
- raise ex, "The specified queue #{name} does not exist."
13
+ set_name_and_url(name_or_url)
17
14
  end
18
15
 
19
16
  def visibility_timeout
@@ -52,6 +49,21 @@ module Shoryuken
52
49
 
53
50
  private
54
51
 
52
+ def set_name_and_url(name_or_url)
53
+ if name_or_url.start_with?('https://sqs.')
54
+ self.name = name_or_url.split('/').last
55
+ self.url = name_or_url
56
+
57
+ # Test if the supplied URL is valid
58
+ fifo?
59
+ else
60
+ self.name = name_or_url
61
+ self.url = client.get_queue_url(queue_name: name_or_url).queue_url
62
+ end
63
+ rescue Aws::Errors::NoSuchEndpointError, Aws::SQS::Errors::NonExistentQueue => ex
64
+ raise ex, "The specified queue #{name} does not exist."
65
+ end
66
+
55
67
  def queue_attributes
56
68
  # Note: Retrieving all queue attributes as requesting `FifoQueue` on non-FIFO queue raises error.
57
69
  # See issue: https://github.com/aws/aws-sdk-ruby/issues/1350
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '3.0.8'.freeze
2
+ VERSION = '3.0.9'.freeze
3
3
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Shoryuken::Queue do
3
+ RSpec.describe Shoryuken::Queue do
4
4
  let(:credentials) { Aws::Credentials.new('access_key_id', 'secret_access_key') }
5
5
  let(:sqs) { Aws::SQS::Client.new(stub_responses: true, credentials: credentials) }
6
6
  let(:queue_name) { 'shoryuken' }
7
- let(:queue_url) { "https://eu-west-1.amazonaws.com:6059/0123456789/#{queue_name}" }
7
+ let(:queue_url) { "https://sqs.eu-west-1.amazonaws.com:6059/0123456789/#{queue_name}" }
8
8
 
9
9
  subject { described_class.new(sqs, queue_name) }
10
10
 
@@ -14,6 +14,16 @@ describe Shoryuken::Queue do
14
14
  allow(subject).to receive(:url).and_return(queue_url)
15
15
  end
16
16
 
17
+ describe '#new' do
18
+ context 'when queue url supplied' do
19
+ subject { described_class.new(sqs, queue_url) }
20
+
21
+ specify do
22
+ expect(subject.name).to eq(queue_name)
23
+ end
24
+ end
25
+ end
26
+
17
27
  describe '#delete_messages' do
18
28
  let(:entries) do
19
29
  [
@@ -105,24 +115,24 @@ describe Shoryuken::Queue do
105
115
 
106
116
  it 'accepts an array of messages' do
107
117
  options = { entries: [{ id: '0',
108
- message_body: 'msg1',
109
- delay_seconds: 1,
110
- message_attributes: { attr: 'attr1' } },
111
- { id: '1',
112
- message_body: 'msg2',
113
- delay_seconds: 1,
114
- message_attributes: { attr: 'attr2' } }] }
118
+ message_body: 'msg1',
119
+ delay_seconds: 1,
120
+ message_attributes: { attr: 'attr1' } },
121
+ { id: '1',
122
+ message_body: 'msg2',
123
+ delay_seconds: 1,
124
+ message_attributes: { attr: 'attr2' } }] }
115
125
 
116
126
  expect(sqs).to receive(:send_message_batch).with(hash_including(options))
117
127
 
118
128
  subject.send_messages([{ message_body: 'msg1',
119
- delay_seconds: 1,
120
- message_attributes: { attr: 'attr1' }
121
- }, {
122
- message_body: 'msg2',
123
- delay_seconds: 1,
124
- message_attributes: { attr: 'attr2' }
125
- }])
129
+ delay_seconds: 1,
130
+ message_attributes: { attr: 'attr1' }
131
+ }, {
132
+ message_body: 'msg2',
133
+ delay_seconds: 1,
134
+ message_attributes: { attr: 'attr2' }
135
+ }])
126
136
  end
127
137
 
128
138
  context 'when FIFO' do
@@ -153,9 +163,9 @@ describe Shoryuken::Queue do
153
163
  end
154
164
 
155
165
  subject.send_messages([{ message_body: 'msg1',
156
- message_attributes: { attr: 'attr1' },
157
- message_group_id: 'my group',
158
- message_deduplication_id: 'my id' }])
166
+ message_attributes: { attr: 'attr1' },
167
+ message_group_id: 'my group',
168
+ message_deduplication_id: 'my id' }])
159
169
  end
160
170
  end
161
171
  end
@@ -179,13 +189,13 @@ describe Shoryuken::Queue do
179
189
  context 'when queue is FIFO' do
180
190
  let(:fifo) { true }
181
191
 
182
- it { expect(subject.fifo?).to be }
192
+ specify { expect(subject.fifo?).to be }
183
193
  end
184
194
 
185
195
  context 'when queue is not FIFO' do
186
196
  let(:fifo) { false }
187
197
 
188
- it { expect(subject.fifo?).to_not be }
198
+ specify { expect(subject.fifo?).to_not be }
189
199
  end
190
200
  end
191
201
  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.0.8
4
+ version: 3.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Cantero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2017-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler