shoryuken 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/shoryuken/environment_loader.rb +2 -2
- data/lib/shoryuken/queue.rb +17 -5
- data/lib/shoryuken/version.rb +1 -1
- data/spec/shoryuken/queue_spec.rb +31 -21
- 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: c88cb34dfa2eae0fbeea81ff493f88c389232edb
|
4
|
+
data.tar.gz: b271d7d9015868d1d5b344d4f338c3e603e57b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7a0ba02ee69d37ee8df087c9c260443cdb9559a48bd1bb58ea93e7c0281a8863acf9e91818b41ce91c211e3569d94fb88cf925ffbad579ccfa33dc917eb431
|
7
|
+
data.tar.gz: dbb15a8ff723305b3db21c01fa74eca91e9f782c07e5d65440eb71a3141969fd9a6bd38d0fe09b15f96260f7580b127c5ba78121f0444b5027ea011464793049
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/shoryuken/queue.rb
CHANGED
@@ -8,12 +8,9 @@ module Shoryuken
|
|
8
8
|
|
9
9
|
attr_accessor :name, :client, :url
|
10
10
|
|
11
|
-
def initialize(client,
|
12
|
-
self.name = name
|
11
|
+
def initialize(client, name_or_url)
|
13
12
|
self.client = client
|
14
|
-
|
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
|
data/lib/shoryuken/version.rb
CHANGED
@@ -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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|