shoryuken 3.1.2 → 3.1.3
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/CHANGELOG.md +8 -0
- data/Gemfile +1 -0
- data/lib/shoryuken.rb +2 -1
- data/lib/shoryuken/environment_loader.rb +25 -11
- data/lib/shoryuken/logging.rb +0 -5
- data/lib/shoryuken/options.rb +4 -0
- data/lib/shoryuken/util.rb +1 -1
- data/lib/shoryuken/version.rb +1 -1
- data/spec/shoryuken/environment_loader_spec.rb +32 -3
- data/spec/shoryuken/middleware/server/timing_spec.rb +5 -3
- data/spec/spec_helper.rb +3 -0
- 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: 942ccdeaca0a94e766b82fa40da9ed091b703ea2
|
4
|
+
data.tar.gz: f94a089b56ed37b5db2752ccf418c667fae31b6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67c92d3af6c4063f42afe07a3f56c32b847bd1bc76d80f4f9f46cc2aa48d3e7bf82213f4d98fe229265ce9b1387a3649652863f019e73aeb0d809b1a03c5ca4d
|
7
|
+
data.tar.gz: 1215eca9e669975edb70fa43855122e6f25c6e54452771ba26435f7e8df37684be20516037e1419a3e7d93a14773231387f471cc2ff8a03eb838f1e52f2c144d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [v3.1.3] - 2017-07-11
|
2
|
+
|
3
|
+
- Add queue prefixing support for groups
|
4
|
+
- [#405](https://github.com/phstc/shoryuken/pull/405)
|
5
|
+
|
6
|
+
- Remove dead code
|
7
|
+
- [#402](https://github.com/phstc/shoryuken/pull/402)
|
8
|
+
|
1
9
|
## [v3.1.2] - 2017-07-06
|
2
10
|
|
3
11
|
- Fix stack level too deep on Ubuntu
|
data/Gemfile
CHANGED
data/lib/shoryuken.rb
CHANGED
@@ -34,6 +34,7 @@ module Shoryuken
|
|
34
34
|
|
35
35
|
def_delegators(
|
36
36
|
:'Shoryuken::Options',
|
37
|
+
:active_job?,
|
37
38
|
:add_group,
|
38
39
|
:groups,
|
39
40
|
:add_queue,
|
@@ -67,4 +68,4 @@ module Shoryuken
|
|
67
68
|
)
|
68
69
|
end
|
69
70
|
|
70
|
-
require 'shoryuken/extensions/active_job_adapter' if
|
71
|
+
require 'shoryuken/extensions/active_job_adapter' if Shoryuken.active_job?
|
@@ -44,7 +44,7 @@ module Shoryuken
|
|
44
44
|
|
45
45
|
fail ArgumentError, "The supplied config file #{path} does not exist" unless File.exist?(path)
|
46
46
|
|
47
|
-
if result = YAML.load(ERB.new(IO.read(path)).result)
|
47
|
+
if (result = YAML.load(ERB.new(IO.read(path)).result))
|
48
48
|
result.deep_symbolize_keys
|
49
49
|
else
|
50
50
|
{}
|
@@ -69,7 +69,7 @@ module Shoryuken
|
|
69
69
|
::Rails::Application.initializer 'shoryuken.eager_load' do
|
70
70
|
::Rails.application.config.eager_load = true
|
71
71
|
end
|
72
|
-
require 'shoryuken/extensions/active_job_adapter' if
|
72
|
+
require 'shoryuken/extensions/active_job_adapter' if Shoryuken.active_job?
|
73
73
|
require File.expand_path('config/environment.rb')
|
74
74
|
end
|
75
75
|
end
|
@@ -85,22 +85,36 @@ module Shoryuken
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
89
|
-
return unless defined? ::ActiveJob
|
90
|
-
return unless Shoryuken.active_job_queue_name_prefixing
|
91
|
-
|
88
|
+
def prefix_active_job_queue_name(queue_name, weight)
|
92
89
|
queue_name_prefix = ::ActiveJob::Base.queue_name_prefix
|
93
90
|
queue_name_delimiter = ::ActiveJob::Base.queue_name_delimiter
|
94
91
|
|
95
92
|
# See https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_name.rb#L27
|
93
|
+
name_parts = [queue_name_prefix.presence, queue_name]
|
94
|
+
prefixed_queue_name = name_parts.compact.join(queue_name_delimiter)
|
95
|
+
[prefixed_queue_name, weight]
|
96
|
+
end
|
97
|
+
|
98
|
+
def prefix_active_job_queue_names
|
99
|
+
return unless Shoryuken.active_job?
|
100
|
+
return unless Shoryuken.active_job_queue_name_prefixing
|
101
|
+
|
96
102
|
Shoryuken.options[:queues].to_a.map! do |queue_name, weight|
|
97
|
-
|
98
|
-
|
99
|
-
|
103
|
+
prefix_active_job_queue_name(queue_name, weight)
|
104
|
+
end
|
105
|
+
|
106
|
+
Shoryuken.options[:groups].to_a.map! do |group, options|
|
107
|
+
if options[:queues]
|
108
|
+
options[:queues].map! do |queue_name, weight|
|
109
|
+
prefix_active_job_queue_name(queue_name, weight)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
[group, options]
|
100
114
|
end
|
101
115
|
end
|
102
116
|
|
103
|
-
def parse_queue(queue, weight
|
117
|
+
def parse_queue(queue, weight, group)
|
104
118
|
Shoryuken.add_queue(queue, [weight.to_i, 1].max, group)
|
105
119
|
end
|
106
120
|
|
@@ -155,7 +169,7 @@ module Shoryuken
|
|
155
169
|
end
|
156
170
|
|
157
171
|
def validate_workers
|
158
|
-
return if
|
172
|
+
return if Shoryuken.active_job?
|
159
173
|
|
160
174
|
all_queues = Shoryuken.ungrouped_queues
|
161
175
|
queues_with_workers = Shoryuken.worker_registry.queues
|
data/lib/shoryuken/logging.rb
CHANGED
@@ -3,7 +3,6 @@ require 'logger'
|
|
3
3
|
|
4
4
|
module Shoryuken
|
5
5
|
module Logging
|
6
|
-
|
7
6
|
class Pretty < Logger::Formatter
|
8
7
|
# Provide a call() method that returns the formatted message.
|
9
8
|
def call(severity, time, program_name, message)
|
@@ -37,9 +36,5 @@ module Shoryuken
|
|
37
36
|
def self.logger=(log)
|
38
37
|
@logger = (log ? log : Logger.new('/dev/null'))
|
39
38
|
end
|
40
|
-
|
41
|
-
def logger
|
42
|
-
shoryuken::Logging.logger
|
43
|
-
end
|
44
39
|
end
|
45
40
|
end
|
data/lib/shoryuken/options.rb
CHANGED
data/lib/shoryuken/util.rb
CHANGED
data/lib/shoryuken/version.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'active_job'
|
2
3
|
|
3
|
-
# rubocop:disable Metrics/BlockLength
|
4
4
|
RSpec.describe Shoryuken::EnvironmentLoader do
|
5
5
|
subject { described_class.new({}) }
|
6
6
|
|
7
7
|
describe '#parse_queues' do
|
8
8
|
before do
|
9
|
-
|
10
|
-
allow(subject).to receive(:load_rails).with(anything)
|
9
|
+
allow(subject).to receive(:load_rails)
|
11
10
|
allow(subject).to receive(:prefix_active_job_queue_names)
|
12
11
|
allow(subject).to receive(:require_workers)
|
13
12
|
allow(subject).to receive(:validate_queues)
|
@@ -22,4 +21,34 @@ RSpec.describe Shoryuken::EnvironmentLoader do
|
|
22
21
|
expect(Shoryuken.groups['default'][:queues]).to eq(%w(queue1 queue2 queue2))
|
23
22
|
end
|
24
23
|
end
|
24
|
+
|
25
|
+
describe '#prefix_active_job_queue_names' do
|
26
|
+
before do
|
27
|
+
allow(subject).to receive(:load_rails)
|
28
|
+
allow(subject).to receive(:require_workers)
|
29
|
+
allow(subject).to receive(:validate_queues)
|
30
|
+
allow(subject).to receive(:validate_workers)
|
31
|
+
allow(subject).to receive(:patch_deprecated_workers)
|
32
|
+
|
33
|
+
ActiveJob::Base.queue_name_prefix = 'test'
|
34
|
+
ActiveJob::Base.queue_name_delimiter = '_'
|
35
|
+
|
36
|
+
allow(Shoryuken).to receive(:active_job?).and_return(true)
|
37
|
+
end
|
38
|
+
|
39
|
+
specify do
|
40
|
+
Shoryuken.active_job_queue_name_prefixing = true
|
41
|
+
|
42
|
+
Shoryuken.options[:queues] = ['queue1', ['queue2', 2]]
|
43
|
+
|
44
|
+
Shoryuken.options[:groups] = {
|
45
|
+
'group1' => { queues: %w(group1_queue1 group1_queue2) }
|
46
|
+
}
|
47
|
+
|
48
|
+
subject.load
|
49
|
+
|
50
|
+
expect(Shoryuken.groups['default'][:queues]).to eq(%w(test_queue1 test_queue2 test_queue2))
|
51
|
+
expect(Shoryuken.groups['group1'][:queues]).to eq(%w(test_group1_queue1 test_group1_queue2))
|
52
|
+
end
|
53
|
+
end
|
25
54
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Shoryuken::Middleware::Server::Timing do
|
3
|
+
RSpec.describe Shoryuken::Middleware::Server::Timing do
|
4
4
|
let(:queue) { 'default' }
|
5
5
|
let(:sqs_queue) { double Shoryuken::Queue, visibility_timeout: 60 }
|
6
6
|
|
7
7
|
let(:sqs_msg) do
|
8
|
-
double
|
8
|
+
double(
|
9
|
+
Shoryuken::Message,
|
9
10
|
queue_url: queue,
|
10
11
|
body: 'test',
|
11
12
|
message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e'
|
13
|
+
)
|
12
14
|
end
|
13
15
|
|
14
16
|
before do
|
@@ -28,7 +30,7 @@ describe Shoryuken::Middleware::Server::Timing do
|
|
28
30
|
|
29
31
|
context 'when exceeded the `visibility_timeout`' do
|
30
32
|
it 'logs exceeded' do
|
31
|
-
allow(subject).to receive(:elapsed).and_return(
|
33
|
+
allow(subject).to receive(:elapsed).and_return(120_000)
|
32
34
|
|
33
35
|
expect(Shoryuken.logger).to receive(:info) do |&block|
|
34
36
|
expect(block.call).to match(/started at/)
|
data/spec/spec_helper.rb
CHANGED
@@ -52,11 +52,14 @@ RSpec.configure do |config|
|
|
52
52
|
TestWorker.get_shoryuken_options.clear
|
53
53
|
TestWorker.get_shoryuken_options['queue'] = 'default'
|
54
54
|
|
55
|
+
Shoryuken.active_job_queue_name_prefixing = false
|
56
|
+
|
55
57
|
Shoryuken.worker_registry.clear
|
56
58
|
Shoryuken.register_worker('default', TestWorker)
|
57
59
|
|
58
60
|
Aws.config[:stub_responses] = true
|
59
61
|
|
60
62
|
allow(Concurrent).to receive(:global_io_executor).and_return(Concurrent::ImmediateExecutor.new)
|
63
|
+
allow(Shoryuken).to receive(:active_job?).and_return(false)
|
61
64
|
end
|
62
65
|
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.1.
|
4
|
+
version: 3.1.3
|
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-07-
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|