shoryuken 5.2.1 → 5.2.3

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: bfdadf90a17ca05fbad43a5d38efc22179415f06b661b587cf5b087d0c200174
4
- data.tar.gz: ca814528eaef23167aca0003fa62e180944ce3bc686d54728c9c30f82732a385
3
+ metadata.gz: 0f2f8c9e8573b699391a74a70d26756e106ccf72b3df9a6fccc32b72d13ec0cd
4
+ data.tar.gz: 6a009d5a5e571da339d52a08f4ccda19f144ce06132f4a65e95fabc39aeffad4
5
5
  SHA512:
6
- metadata.gz: 680c478f59a3feb96c2ed27c6d169c3ad78d37191acf374dff456365a12611b3dba4c0b077e29808d55867446ab2a5008eca6db11f0707aa1a38caea5561d8ee
7
- data.tar.gz: d0e80fc907715d307d6657f6f507643f732c417dc59f888c7123288a416f662a458aa15878516c79b4b9730ef5a306ba33d778354fc8d5cd7cbe448fd76a6a9c
6
+ metadata.gz: e359eee09d82a917c4e13541a121c61f78587421a7e5977052552a4f18512eeb9a2eb720ebc8adf323d0a33fd979b37e9c059a95b5b180eda93cab5a3e034f6b
7
+ data.tar.gz: 5217287d2b7f66125852ac0b824353d934a2a8568e2dc07ca3c98f8991cad1a0dafbda87967a407bc5efaea62b1cafa85708e1ea17ccb659b2743878d079a267
@@ -9,8 +9,8 @@ jobs:
9
9
  name: All Specs
10
10
  strategy:
11
11
  matrix:
12
- ruby: ['2.4.4', '2.5.1', '2.6.3']
13
- gemfile: ['Gemfile', 'Gemfile.aws-sdk-core-v2']
12
+ ruby: ['2.4', '2.5', '2.6', '2.7', '3.0']
13
+ gemfile: ['Gemfile', 'gemfiles/aws_sdk_core_2.gemfile']
14
14
  runs-on: ubuntu-20.04
15
15
  services:
16
16
  moto_sqs:
data/Appraisals CHANGED
@@ -1,3 +1,11 @@
1
+ appraise 'aws_sdk_core_2' do
2
+ group :test do
3
+ gem 'aws-sdk-core', '~> 2'
4
+ gem 'webrick' # required for Ruby 3
5
+ remove_gem 'aws-sdk-sqs'
6
+ end
7
+ end
8
+
1
9
  appraise 'rails_4_2' do
2
10
  group :test do
3
11
  gem 'activejob', '~> 4.2'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [v5.2.3] - 2021-07-29
2
+
3
+ - Fire new `:utilization_update` event any time a worker pool's utilization changes
4
+ - [#673](https://github.com/ruby-shoryuken/shoryuken/pull/673)
5
+
6
+ ## [v5.2.2] - 2021-06-22
7
+
8
+ - When using ActiveJob queue name prefixing, avoid applying prefix to queues configured with a URL or ARN
9
+ - [#667](https://github.com/ruby-shoryuken/shoryuken/pull/667)
10
+
1
11
  ## [v5.2.1] - 2021-04-06
2
12
 
3
13
  - Reduce message batch sizes in `shoryuken sqs requeue` and `shoryuken sqs mv` commands
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ group :test do
6
+ gem "activejob"
7
+ gem "aws-sdk-core", "~> 2"
8
+ gem "codeclimate-test-reporter", require: nil
9
+ gem "httparty"
10
+ gem "multi_xml"
11
+ gem "simplecov"
12
+ gem "webrick"
13
+ end
14
+
15
+ group :development do
16
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
17
+ gem "pry-byebug", "3.9.0"
18
+ gem "rubocop"
19
+ end
20
+
21
+ gemspec path: "../"
@@ -80,6 +80,8 @@ module Shoryuken
80
80
  end
81
81
 
82
82
  def prefix_active_job_queue_name(queue_name, weight)
83
+ return [queue_name, weight] if queue_name.start_with?('https://', 'arn:')
84
+
83
85
  queue_name_prefix = ::ActiveJob::Base.queue_name_prefix
84
86
  queue_name_delimiter = ::ActiveJob::Base.queue_name_delimiter
85
87
 
@@ -71,6 +71,7 @@ module Shoryuken
71
71
  def create_managers
72
72
  Shoryuken.groups.map do |group, options|
73
73
  Shoryuken::Manager.new(
74
+ group,
74
75
  Shoryuken::Fetcher.new(group),
75
76
  Shoryuken.polling_strategy(group).new(options[:queues], Shoryuken.delay(group)),
76
77
  options[:concurrency],
@@ -6,7 +6,8 @@ module Shoryuken
6
6
  # See https://github.com/phstc/shoryuken/issues/348#issuecomment-292847028
7
7
  MIN_DISPATCH_INTERVAL = 0.1
8
8
 
9
- def initialize(fetcher, polling_strategy, concurrency, executor)
9
+ def initialize(group, fetcher, polling_strategy, concurrency, executor)
10
+ @group = group
10
11
  @fetcher = fetcher
11
12
  @polling_strategy = polling_strategy
12
13
  @max_processors = concurrency
@@ -16,6 +17,7 @@ module Shoryuken
16
17
  end
17
18
 
18
19
  def start
20
+ fire_utilization_update_event
19
21
  dispatch_loop
20
22
  end
21
23
 
@@ -59,6 +61,8 @@ module Shoryuken
59
61
 
60
62
  def processor_done(queue)
61
63
  @busy_processors.decrement
64
+ fire_utilization_update_event
65
+
62
66
  client_queue = Shoryuken::Client.queues(queue)
63
67
  return unless client_queue.fifo?
64
68
  return unless @polling_strategy.respond_to?(:message_processed)
@@ -72,6 +76,7 @@ module Shoryuken
72
76
  logger.debug { "Assigning #{sqs_msg.message_id}" }
73
77
 
74
78
  @busy_processors.increment
79
+ fire_utilization_update_event
75
80
 
76
81
  Concurrent::Promise
77
82
  .execute(executor: @executor) { Processor.process(queue_name, sqs_msg) }
@@ -114,5 +119,13 @@ module Shoryuken
114
119
 
115
120
  @running.make_false
116
121
  end
122
+
123
+ def fire_utilization_update_event
124
+ fire_event :utilization_update, false, {
125
+ group: @group,
126
+ max_processors: @max_processors,
127
+ busy_processors: busy
128
+ }
129
+ end
117
130
  end
118
131
  end
@@ -9,6 +9,7 @@ module Shoryuken
9
9
  lifecycle_events: {
10
10
  startup: [],
11
11
  dispatch: [],
12
+ utilization_update: [],
12
13
  quiet: [],
13
14
  shutdown: []
14
15
  }
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '5.2.1'.freeze
2
+ VERSION = '5.2.3'.freeze
3
3
  end
@@ -57,11 +57,11 @@ RSpec.describe Shoryuken::EnvironmentLoader do
57
57
  ActiveJob::Base.queue_name_delimiter = '_'
58
58
 
59
59
  allow(Shoryuken).to receive(:active_job?).and_return(true)
60
- end
61
60
 
62
- specify do
63
61
  Shoryuken.active_job_queue_name_prefixing = true
62
+ end
64
63
 
64
+ specify do
65
65
  Shoryuken.options[:queues] = ['queue1', ['queue2', 2]]
66
66
 
67
67
  Shoryuken.options[:groups] = {
@@ -73,6 +73,26 @@ RSpec.describe Shoryuken::EnvironmentLoader do
73
73
  expect(Shoryuken.groups['default'][:queues]).to eq(%w[test_queue1 test_queue2 test_queue2])
74
74
  expect(Shoryuken.groups['group1'][:queues]).to eq(%w[test_group1_queue1 test_group1_queue2])
75
75
  end
76
+
77
+ it 'does not prefix url-based queues' do
78
+ Shoryuken.options[:queues] = ['https://example.com/test_queue1']
79
+ Shoryuken.options[:groups] = {'group1' => {queues: ['https://example.com/test_group1_queue1']}}
80
+
81
+ subject.load
82
+
83
+ expect(Shoryuken.groups['default'][:queues]).to(eq(['https://example.com/test_queue1']))
84
+ expect(Shoryuken.groups['group1'][:queues]).to(eq(['https://example.com/test_group1_queue1']))
85
+ end
86
+
87
+ it 'does not prefix arn-based queues' do
88
+ 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']}}
90
+
91
+ subject.load
92
+
93
+ expect(Shoryuken.groups['default'][:queues]).to(eq(['arn:aws:sqs:fake-region-1:1234:test_queue1']))
94
+ expect(Shoryuken.groups['group1'][:queues]).to(eq(['arn:aws:sqs:fake-region-1:1234:test_group1_queue1']))
95
+ end
76
96
  end
77
97
  describe "#setup_options" do
78
98
  let (:cli_queues) { { "queue1"=> 10, "queue2" => 20 } }
@@ -15,7 +15,7 @@ RSpec.describe Shoryuken::Manager do
15
15
  let(:concurrency) { 1 }
16
16
  let(:executor) { Concurrent::ImmediateExecutor.new }
17
17
 
18
- subject { Shoryuken::Manager.new(fetcher, polling_strategy, concurrency, executor) }
18
+ subject { Shoryuken::Manager.new('default', fetcher, polling_strategy, concurrency, executor) }
19
19
 
20
20
  before do
21
21
  allow(fetcher).to receive(:fetch).and_return([])
@@ -71,6 +71,11 @@ RSpec.describe Shoryuken::Manager do
71
71
 
72
72
  expect(fetcher).to receive(:fetch).with(q, concurrency).and_return(messages)
73
73
  expect(subject).to receive(:fire_event).with(:dispatch, false, queue_name: q.name)
74
+ expect(subject).to receive(:fire_event).with(:utilization_update,
75
+ false,
76
+ group: 'default',
77
+ busy_processors: 1,
78
+ max_processors: 1)
74
79
  expect(Shoryuken::Processor).to receive(:process).with(q, message)
75
80
  expect(Shoryuken.logger).to receive(:info).never
76
81
 
@@ -99,6 +104,11 @@ RSpec.describe Shoryuken::Manager do
99
104
  q = Shoryuken::Polling::QueueConfiguration.new(queue, {})
100
105
 
101
106
  expect(fetcher).to receive(:fetch).with(q, described_class::BATCH_LIMIT).and_return(messages)
107
+ expect(subject).to receive(:fire_event).with(:utilization_update,
108
+ false,
109
+ group: 'default',
110
+ busy_processors: 1,
111
+ max_processors: 1)
102
112
  expect(subject).to receive(:fire_event).with(:dispatch, false, queue_name: q.name)
103
113
  allow(subject).to receive(:batched_queue?).with(q).and_return(true)
104
114
  expect(Shoryuken::Processor).to receive(:process).with(q, messages)
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.2.1
4
+ version: 5.2.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: 2021-04-07 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -112,7 +112,6 @@ files:
112
112
  - Appraisals
113
113
  - CHANGELOG.md
114
114
  - Gemfile
115
- - Gemfile.aws-sdk-core-v2
116
115
  - LICENSE
117
116
  - README.md
118
117
  - Rakefile
@@ -122,6 +121,7 @@ files:
122
121
  - examples/bootstrap_queues.rb
123
122
  - examples/default_worker.rb
124
123
  - gemfiles/.gitignore
124
+ - gemfiles/aws_sdk_core_2.gemfile
125
125
  - gemfiles/rails_4_2.gemfile
126
126
  - gemfiles/rails_5_2.gemfile
127
127
  - gemfiles/rails_6_0.gemfile
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in shoryuken.gemspec
4
- gemspec
5
-
6
- group :test do
7
- gem 'activejob', '~> 4'
8
- gem 'aws-sdk-core', '~> 2'
9
- gem 'codeclimate-test-reporter', require: nil
10
- gem 'httparty'
11
- gem 'multi_xml'
12
- gem 'simplecov'
13
- end