shoryuken 5.3.1 → 5.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/shoryuken/environment_loader.rb +9 -1
- data/lib/shoryuken/polling/strict_priority.rb +4 -2
- data/lib/shoryuken/polling/weighted_round_robin.rb +3 -5
- data/lib/shoryuken/version.rb +1 -1
- data/spec/shoryuken/environment_loader_spec.rb +39 -6
- data/spec/shoryuken/polling/weighted_round_robin_spec.rb +31 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1002845b2232c5f7491b2839d7851be5afdb79a3a11e73e2249b81e1f2ea4ec4
|
4
|
+
data.tar.gz: 8398fa557fba47360763bb83ea4e0f529b2c69bad8b15fb3163e03c517b460d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 010d2f45fe45e6967435b57c1f0c7601f9d3a43a8c1108edbf97b303e60e108e0c6be1ba28915a43bc84f5904bd7f3d634916251b8b1c0d83143d75bdccaaca7
|
7
|
+
data.tar.gz: 00c8f19de3a9fd241bb236023479bd5c3bd27f731001f036377c05b75c18bce119b08666eb13649606904e2950f937f52615eba84facb44074099fde1fc97534
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [v5.3.2] - 2022-01-19
|
2
|
+
|
3
|
+
- (Bugfix) Preserve queue weights when unpausing queues
|
4
|
+
- [#687](https://github.com/ruby-shoryuken/shoryuken/pull/687)
|
5
|
+
|
6
|
+
- Improve error message on startup when shoryuken has insufficient permissions to access a queue
|
7
|
+
- [#691](https://github.com/ruby-shoryuken/shoryuken/pull/691)
|
8
|
+
|
1
9
|
## [v5.3.1] - 2022-01-07
|
2
10
|
|
3
11
|
- (Bugfix) Fix issue where, when using the TSTP or USR1 signals for soft shutdowns, it was possible for shoryuken to terminate without first attempting to handle all messages it fetched from SQS
|
@@ -159,9 +159,17 @@ module Shoryuken
|
|
159
159
|
|
160
160
|
return if non_existent_queues.none?
|
161
161
|
|
162
|
+
# NOTE: HEREDOC's ~ operator removes indents, but is only available Ruby 2.3+
|
163
|
+
# See github PR: https://github.com/ruby-shoryuken/shoryuken/pull/691#issuecomment-1007653595
|
164
|
+
error_msg = <<-MSG.gsub(/^\s+/, '')
|
165
|
+
The specified queue(s) #{non_existent_queues.join(', ')} do not exist.
|
166
|
+
Try 'shoryuken sqs create QUEUE-NAME' for creating a queue with default settings.
|
167
|
+
It's also possible that you don't have permission to access the specified queues.
|
168
|
+
MSG
|
169
|
+
|
162
170
|
fail(
|
163
171
|
ArgumentError,
|
164
|
-
|
172
|
+
error_msg
|
165
173
|
)
|
166
174
|
end
|
167
175
|
|
@@ -39,8 +39,10 @@ module Shoryuken
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def message_processed(queue)
|
42
|
-
|
43
|
-
|
42
|
+
if queue_paused?(queue)
|
43
|
+
logger.debug "Unpausing #{queue}"
|
44
|
+
@paused_until[queue] = Time.at 0
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
48
|
private
|
@@ -36,12 +36,10 @@ module Shoryuken
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def message_processed(queue)
|
39
|
-
|
39
|
+
paused_queue = @paused_queues.find { |_time, name| name == queue }
|
40
|
+
return unless paused_queue
|
40
41
|
|
41
|
-
|
42
|
-
@paused_queues.reject! { |_time, name| name == queue }
|
43
|
-
@queues << queue
|
44
|
-
@queues.uniq!
|
42
|
+
paused_queue[0] = Time.at 0
|
45
43
|
end
|
46
44
|
|
47
45
|
private
|
data/lib/shoryuken/version.rb
CHANGED
@@ -4,6 +4,36 @@ require 'active_job'
|
|
4
4
|
RSpec.describe Shoryuken::EnvironmentLoader do
|
5
5
|
subject { described_class.new({}) }
|
6
6
|
|
7
|
+
describe '#load' do
|
8
|
+
before do
|
9
|
+
Shoryuken.groups.clear
|
10
|
+
# See issue: https://stackoverflow.com/a/63699568 for stubbing AWS errors
|
11
|
+
allow(Shoryuken::Client)
|
12
|
+
.to receive(:queues)
|
13
|
+
.with('stubbed_queue')
|
14
|
+
.and_raise(Aws::SQS::Errors::NonExistentQueue.new(nil, nil))
|
15
|
+
allow(subject).to receive(:load_rails)
|
16
|
+
allow(subject).to receive(:prefix_active_job_queue_names)
|
17
|
+
allow(subject).to receive(:require_workers)
|
18
|
+
allow(subject).to receive(:validate_workers)
|
19
|
+
allow(subject).to receive(:patch_deprecated_workers)
|
20
|
+
Shoryuken.options[:groups] = [['custom', { queues: ['stubbed_queue'] }]]
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when given queues don't exist" do
|
24
|
+
specify do
|
25
|
+
expect { subject.load }.to raise_error(
|
26
|
+
ArgumentError,
|
27
|
+
<<-MSG.gsub(/^\s+/, '')
|
28
|
+
The specified queue(s) stubbed_queue do not exist.
|
29
|
+
Try 'shoryuken sqs create QUEUE-NAME' for creating a queue with default settings.
|
30
|
+
It's also possible that you don't have permission to access the specified queues.
|
31
|
+
MSG
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
7
37
|
describe '#parse_queues loads default queues' do
|
8
38
|
before do
|
9
39
|
allow(subject).to receive(:load_rails)
|
@@ -34,7 +64,7 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
34
64
|
|
35
65
|
specify do
|
36
66
|
Shoryuken.options[:queues] = ['queue1', 'queue2'] # default queues
|
37
|
-
Shoryuken.options[:groups] = [[
|
67
|
+
Shoryuken.options[:groups] = [['custom', { queues: ['queue3'], delay: 25 }]]
|
38
68
|
subject.load
|
39
69
|
|
40
70
|
expect(Shoryuken.groups['default'][:queues]).to eq(%w[queue1 queue2])
|
@@ -44,7 +74,6 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
44
74
|
end
|
45
75
|
end
|
46
76
|
|
47
|
-
|
48
77
|
describe '#prefix_active_job_queue_names' do
|
49
78
|
before do
|
50
79
|
allow(subject).to receive(:load_rails)
|
@@ -76,7 +105,7 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
76
105
|
|
77
106
|
it 'does not prefix url-based queues' do
|
78
107
|
Shoryuken.options[:queues] = ['https://example.com/test_queue1']
|
79
|
-
Shoryuken.options[:groups] = {'group1' => {queues: ['https://example.com/test_group1_queue1']}}
|
108
|
+
Shoryuken.options[:groups] = { 'group1' => { queues: ['https://example.com/test_group1_queue1'] } }
|
80
109
|
|
81
110
|
subject.load
|
82
111
|
|
@@ -86,7 +115,7 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
86
115
|
|
87
116
|
it 'does not prefix arn-based queues' do
|
88
117
|
Shoryuken.options[:queues] = ['arn:aws:sqs:fake-region-1:1234:test_queue1']
|
89
|
-
Shoryuken.options[:groups] = {'group1' => {queues: ['arn:aws:sqs:fake-region-1:1234:test_group1_queue1']}}
|
118
|
+
Shoryuken.options[:groups] = { 'group1' => { queues: ['arn:aws:sqs:fake-region-1:1234:test_group1_queue1'] } }
|
90
119
|
|
91
120
|
subject.load
|
92
121
|
|
@@ -94,9 +123,11 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
94
123
|
expect(Shoryuken.groups['group1'][:queues]).to(eq(['arn:aws:sqs:fake-region-1:1234:test_group1_queue1']))
|
95
124
|
end
|
96
125
|
end
|
126
|
+
|
97
127
|
describe "#setup_options" do
|
98
|
-
let
|
99
|
-
let
|
128
|
+
let(:cli_queues) { { "queue1" => 10, "queue2" => 20 } }
|
129
|
+
let(:config_queues) { [["queue1", 8], ["queue2", 4]] }
|
130
|
+
|
100
131
|
context "when given queues through config and CLI" do
|
101
132
|
specify do
|
102
133
|
allow_any_instance_of(Shoryuken::EnvironmentLoader).to receive(:config_file_options).and_return({ queues: config_queues })
|
@@ -104,6 +135,7 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
104
135
|
expect(Shoryuken.options[:queues]).to eq(cli_queues)
|
105
136
|
end
|
106
137
|
end
|
138
|
+
|
107
139
|
context "when given queues through config only" do
|
108
140
|
specify do
|
109
141
|
allow_any_instance_of(Shoryuken::EnvironmentLoader).to receive(:config_file_options).and_return({ queues: config_queues })
|
@@ -111,6 +143,7 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
111
143
|
expect(Shoryuken.options[:queues]).to eq(config_queues)
|
112
144
|
end
|
113
145
|
end
|
146
|
+
|
114
147
|
context "when given queues through CLI only" do
|
115
148
|
specify do
|
116
149
|
Shoryuken::EnvironmentLoader.setup_options(queues: cli_queues)
|
@@ -106,12 +106,37 @@ RSpec.describe Shoryuken::Polling::WeightedRoundRobin do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
describe '#message_processed' do
|
109
|
-
it 'removes paused queue
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
109
|
+
it 'removes delay from paused queue' do
|
110
|
+
queues << queue1
|
111
|
+
queues << queue2
|
112
|
+
|
113
|
+
expect(subject.next_queue).to eq(queue1)
|
114
|
+
subject.messages_found(queue1, 0) # pauses queue1
|
115
|
+
|
116
|
+
expect(subject.active_queues).to eq([[queue2, 1]])
|
117
|
+
|
118
|
+
subject.message_processed(queue1) # marks queue1 to be unpaused
|
119
|
+
|
120
|
+
expect(subject.next_queue).to eq(queue2) # implicitly unpauses queue1
|
121
|
+
expect(subject.active_queues).to eq([[queue1, 1], [queue2, 1]])
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'preserves weight of queues when unpausing' do
|
125
|
+
queues << queue1
|
126
|
+
queues << queue1
|
127
|
+
queues << queue2
|
128
|
+
|
129
|
+
expect(subject.next_queue).to eq(queue1)
|
130
|
+
subject.messages_found(queue1, 1)
|
131
|
+
|
132
|
+
expect(subject.next_queue).to eq(queue2)
|
133
|
+
subject.messages_found(queue2, 0) # pauses queue2
|
134
|
+
|
135
|
+
expect(subject.active_queues).to eq([[queue1, 2]])
|
136
|
+
subject.message_processed(queue2) # marks queue2 to be unpaused
|
137
|
+
|
138
|
+
expect(subject.next_queue).to eq(queue1) # implicitly unpauses queue2
|
139
|
+
expect(subject.active_queues).to eq([[queue1, 2], [queue2, 1]])
|
115
140
|
end
|
116
141
|
end
|
117
142
|
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: 5.3.
|
4
|
+
version: 5.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Cantero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|