sidekiq-throttled 0.15.1 → 0.16.0
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/.github/workflows/ci.yml +9 -8
- data/.rubocop.yml +8 -7
- data/.rubocop_todo.yml +39 -3
- data/Appraisals +8 -12
- data/CHANGES.md +30 -2
- data/Gemfile +7 -5
- data/LICENSE.md +1 -0
- data/README.md +6 -16
- data/Rakefile +1 -1
- data/gemfiles/sidekiq_6.0.gemfile +7 -5
- data/gemfiles/sidekiq_6.1.gemfile +7 -5
- data/gemfiles/sidekiq_6.2.gemfile +7 -5
- data/gemfiles/sidekiq_6.3.gemfile +7 -5
- data/gemfiles/{sidekiq_5.2.gemfile → sidekiq_6.4.gemfile} +8 -6
- data/gemfiles/{sidekiq_5.1.gemfile → sidekiq_6.5.gemfile} +8 -6
- data/lib/sidekiq/throttled/communicator/callbacks.rb +1 -1
- data/lib/sidekiq/throttled/communicator/exception_handler.rb +25 -0
- data/lib/sidekiq/throttled/communicator/listener.rb +1 -1
- data/lib/sidekiq/throttled/communicator.rb +1 -1
- data/lib/sidekiq/throttled/expirable_list.rb +2 -5
- data/lib/sidekiq/throttled/fetch/unit_of_work.rb +7 -2
- data/lib/sidekiq/throttled/fetch.rb +5 -1
- data/lib/sidekiq/throttled/job.rb +128 -0
- data/lib/sidekiq/throttled/strategy/concurrency.rb +2 -2
- data/lib/sidekiq/throttled/strategy/threshold.rb +2 -2
- data/lib/sidekiq/throttled/version.rb +1 -1
- data/lib/sidekiq/throttled/web/stats.rb +5 -4
- data/lib/sidekiq/throttled/worker.rb +6 -121
- data/lib/sidekiq/throttled.rb +5 -3
- data/{.rubocop → rubocop}/rspec.yml +1 -1
- data/sidekiq-throttled.gemspec +7 -5
- metadata +22 -20
- data/gemfiles/sidekiq_5.0.gemfile +0 -31
- /data/{.rubocop → rubocop}/layout.yml +0 -0
- /data/{.rubocop → rubocop}/lint.yml +0 -0
- /data/{.rubocop → rubocop}/metrics.yml +0 -0
- /data/{.rubocop → rubocop}/performance.yml +0 -0
- /data/{.rubocop → rubocop}/style.yml +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 149c9477c7a02b5a8a48fd0f9d1a665c1cd254a2b5af92c82bb0bbcda92c7907
|
|
4
|
+
data.tar.gz: 2fe05d0217edbdb5e9a66fdbd29149824ba5623d5c2e5d5df2db269d4a003bfc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 165176da74bbeaa33d3f882c8cac2f61e1796184dfcfedb737a9604d49cad86d20c1a9b7a19c8272a7302164825036bcea3a0a2dc78c0312db7dd1ac19f5c64a
|
|
7
|
+
data.tar.gz: 6db474ddc907ee5c97d3b9eb829a338c9a28d5997346031864cbfcda00857a24b49ae36451f92bf112d0985065bbf72443313733bc13075c8e1ebdcab6465c70
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -2,19 +2,19 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: [ main ]
|
|
6
6
|
pull_request:
|
|
7
|
-
branches: [
|
|
7
|
+
branches: [ main ]
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
|
-
|
|
10
|
+
test:
|
|
11
11
|
name: "rspec (ruby:${{ matrix.ruby }} sidekiq:${{ matrix.sidekiq }})"
|
|
12
12
|
|
|
13
13
|
strategy:
|
|
14
14
|
fail-fast: false
|
|
15
15
|
matrix:
|
|
16
|
-
ruby: [ "2.
|
|
17
|
-
sidekiq: [ "
|
|
16
|
+
ruby: [ "2.7", "3.0", "3.1" ]
|
|
17
|
+
sidekiq: [ "6.0", "6.1", "6.2", "6.3", "6.4", "6.5" ]
|
|
18
18
|
|
|
19
19
|
runs-on: ubuntu-latest
|
|
20
20
|
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
options: "--entrypoint redis-server"
|
|
26
26
|
|
|
27
27
|
env:
|
|
28
|
-
|
|
28
|
+
BUNDLE_GEMFILE: gemfiles/sidekiq_${{ matrix.sidekiq }}.gemfile
|
|
29
29
|
|
|
30
30
|
steps:
|
|
31
31
|
- uses: actions/checkout@v2
|
|
@@ -35,7 +35,8 @@ jobs:
|
|
|
35
35
|
ruby-version: ${{ matrix.ruby }}
|
|
36
36
|
bundler-cache: true
|
|
37
37
|
|
|
38
|
-
-
|
|
38
|
+
- name: bundle exec rspec
|
|
39
|
+
run: bundle exec rspec --format progress --force-colour
|
|
39
40
|
|
|
40
41
|
rubocop:
|
|
41
42
|
runs-on: ubuntu-latest
|
|
@@ -45,7 +46,7 @@ jobs:
|
|
|
45
46
|
|
|
46
47
|
- uses: ruby/setup-ruby@v1
|
|
47
48
|
with:
|
|
48
|
-
ruby-version: "2.
|
|
49
|
+
ruby-version: "2.7"
|
|
49
50
|
bundler-cache: true
|
|
50
51
|
|
|
51
52
|
- run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
require:
|
|
2
2
|
- rubocop-performance
|
|
3
|
+
- rubocop-rake
|
|
3
4
|
- rubocop-rspec
|
|
4
5
|
|
|
5
6
|
inherit_from:
|
|
6
7
|
- .rubocop_todo.yml
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
8
|
+
- rubocop/layout.yml
|
|
9
|
+
- rubocop/lint.yml
|
|
10
|
+
- rubocop/metrics.yml
|
|
11
|
+
- rubocop/performance.yml
|
|
12
|
+
- rubocop/rspec.yml
|
|
13
|
+
- rubocop/style.yml
|
|
13
14
|
|
|
14
15
|
AllCops:
|
|
15
16
|
Exclude:
|
|
16
17
|
- gemfiles/**/*
|
|
17
18
|
- vendor/**/*
|
|
18
19
|
NewCops: enable
|
|
19
|
-
TargetRubyVersion: 2.
|
|
20
|
+
TargetRubyVersion: 2.7
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2022-06-13 00:11:28 UTC using RuboCop version 1.30.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
9
|
+
# Offense count: 3
|
|
10
|
+
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
|
11
|
+
Lint/EmptyBlock:
|
|
12
|
+
Exclude:
|
|
13
|
+
- 'spec/sidekiq/throttled/middleware_spec.rb'
|
|
14
|
+
- 'spec/sidekiq/throttled/registry_spec.rb'
|
|
15
|
+
|
|
16
|
+
# Offense count: 2
|
|
17
|
+
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
|
18
|
+
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
|
19
|
+
Naming/MemoizedInstanceVariableName:
|
|
20
|
+
Exclude:
|
|
21
|
+
- 'lib/sidekiq/throttled/communicator.rb'
|
|
22
|
+
- 'lib/sidekiq/throttled/queues_pauser.rb'
|
|
23
|
+
|
|
24
|
+
# Offense count: 2
|
|
25
|
+
Performance/MethodObjectAsBlock:
|
|
26
|
+
Exclude:
|
|
27
|
+
- 'lib/sidekiq/throttled/queues_pauser.rb'
|
|
28
|
+
|
|
29
|
+
# Offense count: 2
|
|
30
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
|
31
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
|
32
|
+
RSpec/FilePath:
|
|
33
|
+
Exclude:
|
|
34
|
+
- 'spec/sidekiq/throttled/web/queues_spec.rb'
|
|
35
|
+
- 'spec/sidekiq/throttled/web/throttled_spec.rb'
|
|
36
|
+
|
|
37
|
+
# Offense count: 69
|
|
10
38
|
# Configuration parameters: .
|
|
11
39
|
# SupportedStyles: have_received, receive
|
|
12
40
|
RSpec/MessageSpies:
|
|
@@ -25,8 +53,16 @@ RSpec/MultipleMemoizedHelpers:
|
|
|
25
53
|
RSpec/NestedGroups:
|
|
26
54
|
Max: 5
|
|
27
55
|
|
|
28
|
-
# Offense count:
|
|
56
|
+
# Offense count: 5
|
|
57
|
+
RSpec/StubbedMock:
|
|
58
|
+
Exclude:
|
|
59
|
+
- 'spec/sidekiq/throttled/expirable_list_spec.rb'
|
|
60
|
+
- 'spec/sidekiq/throttled/fetch_spec.rb'
|
|
61
|
+
- 'spec/sidekiq/throttled/queues_pauser_spec.rb'
|
|
62
|
+
|
|
63
|
+
# Offense count: 6
|
|
29
64
|
RSpec/SubjectStub:
|
|
30
65
|
Exclude:
|
|
31
66
|
- 'spec/sidekiq/throttled/communicator_spec.rb'
|
|
67
|
+
- 'spec/sidekiq/throttled/fetch_spec.rb'
|
|
32
68
|
- 'spec/sidekiq/throttled/queues_pauser_spec.rb'
|
data/Appraisals
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
appraise "sidekiq-5.0" do
|
|
4
|
-
gem "sidekiq", "~> 5.0.0"
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
appraise "sidekiq-5.1" do
|
|
8
|
-
gem "sidekiq", "~> 5.1.0"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
appraise "sidekiq-5.2" do
|
|
12
|
-
gem "sidekiq", "~> 5.2.0"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
3
|
appraise "sidekiq-6.0" do
|
|
16
4
|
gem "sidekiq", "~> 6.0.0"
|
|
17
5
|
end
|
|
@@ -27,3 +15,11 @@ end
|
|
|
27
15
|
appraise "sidekiq-6.3" do
|
|
28
16
|
gem "sidekiq", "~> 6.3.0"
|
|
29
17
|
end
|
|
18
|
+
|
|
19
|
+
appraise "sidekiq-6.4" do
|
|
20
|
+
gem "sidekiq", "~> 6.4.0"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
appraise "sidekiq-6.5" do
|
|
24
|
+
gem "sidekiq", "~> 6.5.0"
|
|
25
|
+
end
|
data/CHANGES.md
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
## 0.
|
|
1
|
+
## 0.16.0 (2022-06-13)
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* Drop Ruby 2.6 support.
|
|
4
|
+
|
|
5
|
+
* Drop Sidekiq 5.X support.
|
|
6
|
+
|
|
7
|
+
* [#121](https://github.com/sensortower/sidekiq-throttled/pull/121)
|
|
8
|
+
Sidekiq 6.5 compatibility.
|
|
9
|
+
([@hieuk09])
|
|
10
|
+
|
|
11
|
+
* [#116](https://github.com/sensortower/sidekiq-throttled/pull/116)
|
|
12
|
+
Unwrap ActiveJob JobWrapper
|
|
13
|
+
([@holstvoogd])
|
|
14
|
+
|
|
15
|
+
* [#115](https://github.com/sensortower/sidekiq-throttled/pull/115)
|
|
16
|
+
Fix Redis 4.6 deprecation warnings.
|
|
17
|
+
([@dbackeus])
|
|
18
|
+
|
|
19
|
+
* [#113](https://github.com/sensortower/sidekiq-throttled/pull/113)
|
|
20
|
+
Add Ruby 3.1 to CI.
|
|
21
|
+
([@petergoldstein])
|
|
22
|
+
|
|
23
|
+
* [#103](https://github.com/sensortower/sidekiq-throttled/pull/103)
|
|
24
|
+
Rename Sidekiq::Throttled::Worker to Sidekiq::Throttled::Job, and alias it
|
|
25
|
+
as Sidekiq::Throttled::Worker.
|
|
26
|
+
([@CHTJonas])
|
|
4
27
|
|
|
5
28
|
## 0.15.0 (2021-12-16)
|
|
6
29
|
|
|
@@ -258,3 +281,8 @@
|
|
|
258
281
|
[@mattiagiuffrida-st]: https://github.com/mattiagiuffrida-st
|
|
259
282
|
[@baptistejub]: https://github.com/baptistejub
|
|
260
283
|
[@ybiquitous]: https://github.com/ybiquitous
|
|
284
|
+
[@hieuk09]: https://github.com/hieuk09
|
|
285
|
+
[@petergoldstein]: https://github.com/petergoldstein
|
|
286
|
+
[@dbackeus]: https://github.com/dbackeus
|
|
287
|
+
[@holstvoogd]: https://github.com/holstvoogd
|
|
288
|
+
[@CHTJonas]: https://github.com/CHTJonas
|
data/Gemfile
CHANGED
|
@@ -5,9 +5,6 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "rubocop", "~> 0.90.0", :require => false
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", :require => false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", :require => false
|
|
11
8
|
gem "sidekiq"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
@@ -20,13 +17,18 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", :require => false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", :require => false
|
|
28
|
+
gem "rubocop-performance", :require => false
|
|
29
|
+
gem "rubocop-rake", :require => false
|
|
30
|
+
gem "rubocop-rspec", :require => false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
# Specify your gem's dependencies in sidekiq-throttled.gemspec
|
|
32
34
|
gemspec
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
# Sidekiq::Throttled
|
|
2
2
|
|
|
3
|
+
[](https://github.com/ixti/sidekiq-throttled/actions/workflows/ci.yml)
|
|
3
4
|
[](http://rubygems.org/gems/sidekiq-throttled)
|
|
4
|
-
[](https://github.com/sensortower/sidekiq-throttled/actions?query=workflow%3ACI+branch%3Amaster)
|
|
5
|
-
[](https://codeclimate.com/github/sensortower/sidekiq-throttled)
|
|
6
|
-
[](https://coveralls.io/github/sensortower/sidekiq-throttled?branch=master)
|
|
7
|
-
[](http://inch-ci.org/github/sensortower/sidekiq-throttled)
|
|
8
5
|
[](http://www.rubydoc.info/gems/sidekiq-throttled)
|
|
9
6
|
|
|
10
7
|
Concurrency and threshold throttling for [Sidekiq][sidekiq].
|
|
@@ -230,12 +227,12 @@ end
|
|
|
230
227
|
|
|
231
228
|
## Supported Ruby Versions
|
|
232
229
|
|
|
233
|
-
This library aims to support and is [tested against][
|
|
230
|
+
This library aims to support and is [tested against][ci] the following Ruby
|
|
234
231
|
versions:
|
|
235
232
|
|
|
236
|
-
* Ruby 2.6.x
|
|
237
233
|
* Ruby 2.7.x
|
|
238
234
|
* Ruby 3.0.x
|
|
235
|
+
* Ruby 3.1.x
|
|
239
236
|
|
|
240
237
|
If something doesn't work on one of these versions, it's a bug.
|
|
241
238
|
|
|
@@ -255,13 +252,12 @@ dropped.
|
|
|
255
252
|
|
|
256
253
|
This library aims to support work with following [Sidekiq][sidekiq] versions:
|
|
257
254
|
|
|
258
|
-
* Sidekiq 5.0.x
|
|
259
|
-
* Sidekiq 5.1.x
|
|
260
|
-
* Sidekiq 5.2.x
|
|
261
255
|
* Sidekiq 6.0.x
|
|
262
256
|
* Sidekiq 6.1.x
|
|
263
257
|
* Sidekiq 6.2.x
|
|
264
258
|
* Sidekiq 6.3.x
|
|
259
|
+
* Sidekiq 6.4.x
|
|
260
|
+
* Sidekiq 6.5.x
|
|
265
261
|
|
|
266
262
|
|
|
267
263
|
## Contributing
|
|
@@ -287,11 +283,5 @@ bundle exec rubocop # run static code analysis
|
|
|
287
283
|
Don't forget to run `appraisal update` after any changes to `Gemfile`.
|
|
288
284
|
|
|
289
285
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
Copyright (c) 2020-2021 Alexey Zapparov, SensorTower Inc.
|
|
293
|
-
See LICENSE.md for further details.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
[travis]: http://travis-ci.org/sensortower/sidekiq-throttled
|
|
286
|
+
[ci]: https://github.com/ixti/sidekiq-throttled/actions/workflows/ci.yml
|
|
297
287
|
[sidekiq]: https://github.com/mperham/sidekiq
|
data/Rakefile
CHANGED
|
@@ -24,4 +24,4 @@ end
|
|
|
24
24
|
default_suite = ENV["CI"] ? :spec : %i[spec rubocop]
|
|
25
25
|
named_suites = { "rubocop" => :rubocop, "rspec" => :spec }
|
|
26
26
|
|
|
27
|
-
task :default => named_suites.fetch(ENV
|
|
27
|
+
task :default => named_suites.fetch(ENV.fetch("SUITE", nil), default_suite)
|
|
@@ -5,9 +5,6 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "rubocop", "~> 0.90.0", require: false
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
8
|
gem "sidekiq", "~> 6.0.0"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
@@ -20,12 +17,17 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", require: false
|
|
28
|
+
gem "rubocop-performance", require: false
|
|
29
|
+
gem "rubocop-rake", require: false
|
|
30
|
+
gem "rubocop-rspec", require: false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
gemspec path: "../"
|
|
@@ -5,9 +5,6 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "rubocop", "~> 0.90.0", require: false
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
8
|
gem "sidekiq", "~> 6.1.0"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
@@ -20,12 +17,17 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", require: false
|
|
28
|
+
gem "rubocop-performance", require: false
|
|
29
|
+
gem "rubocop-rake", require: false
|
|
30
|
+
gem "rubocop-rspec", require: false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
gemspec path: "../"
|
|
@@ -5,9 +5,6 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "rubocop", "~> 0.90.0", require: false
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
8
|
gem "sidekiq", "~> 6.2.0"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
@@ -20,12 +17,17 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", require: false
|
|
28
|
+
gem "rubocop-performance", require: false
|
|
29
|
+
gem "rubocop-rake", require: false
|
|
30
|
+
gem "rubocop-rspec", require: false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
gemspec path: "../"
|
|
@@ -5,9 +5,6 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "rubocop", "~> 0.90.0", require: false
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
8
|
gem "sidekiq", "~> 6.3.0"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
@@ -20,12 +17,17 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", require: false
|
|
28
|
+
gem "rubocop-performance", require: false
|
|
29
|
+
gem "rubocop-rake", require: false
|
|
30
|
+
gem "rubocop-rspec", require: false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
gemspec path: "../"
|
|
@@ -5,10 +5,7 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
|
-
gem "sidekiq", "~> 5.2.0"
|
|
8
|
+
gem "sidekiq", "~> 6.4.0"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
14
11
|
gem "byebug"
|
|
@@ -20,12 +17,17 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", require: false
|
|
28
|
+
gem "rubocop-performance", require: false
|
|
29
|
+
gem "rubocop-rake", require: false
|
|
30
|
+
gem "rubocop-rspec", require: false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
gemspec path: "../"
|
|
@@ -5,10 +5,7 @@ source "https://rubygems.org"
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
7
|
gem "rspec"
|
|
8
|
-
gem "
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
|
-
gem "sidekiq", "~> 5.1.0"
|
|
8
|
+
gem "sidekiq", "~> 6.5.0"
|
|
12
9
|
|
|
13
10
|
group :development do
|
|
14
11
|
gem "byebug"
|
|
@@ -20,12 +17,17 @@ end
|
|
|
20
17
|
group :test do
|
|
21
18
|
gem "apparition"
|
|
22
19
|
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
20
|
gem "puma"
|
|
25
21
|
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
22
|
gem "sinatra"
|
|
28
23
|
gem "timecop"
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
group :lint do
|
|
27
|
+
gem "rubocop", require: false
|
|
28
|
+
gem "rubocop-performance", require: false
|
|
29
|
+
gem "rubocop-rake", require: false
|
|
30
|
+
gem "rubocop-rspec", require: false
|
|
31
|
+
end
|
|
32
|
+
|
|
31
33
|
gemspec path: "../"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "sidekiq"
|
|
4
|
+
require "sidekiq/version"
|
|
5
|
+
|
|
6
|
+
module Sidekiq
|
|
7
|
+
module Throttled
|
|
8
|
+
class Communicator
|
|
9
|
+
if Sidekiq::VERSION >= "6.5.0"
|
|
10
|
+
module ExceptionHandler
|
|
11
|
+
def handle_exception(*args)
|
|
12
|
+
Sidekiq.handle_exception(*args)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# NOTE: `Sidekiq.default_error_handler` is private API
|
|
17
|
+
Sidekiq.error_handlers << Sidekiq.method(:default_error_handler)
|
|
18
|
+
else
|
|
19
|
+
require "sidekiq/exception_handler"
|
|
20
|
+
|
|
21
|
+
ExceptionHandler = ::Sidekiq::ExceptionHandler
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require "monitor"
|
|
4
4
|
|
|
5
|
-
require "concurrent/utility/monotonic_time"
|
|
6
|
-
|
|
7
5
|
module Sidekiq
|
|
8
6
|
module Throttled
|
|
9
7
|
# List that tracks when elements were added and enumerates over those not
|
|
@@ -24,7 +22,6 @@ module Sidekiq
|
|
|
24
22
|
# It does not deduplicates elements. Eviction happens only upon elements
|
|
25
23
|
# retrieval (see {#each}).
|
|
26
24
|
#
|
|
27
|
-
# @see http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#monotonic_time-class_method
|
|
28
25
|
# @see https://ruby-doc.org/core/Process.html#method-c-clock_gettime
|
|
29
26
|
# @see https://linux.die.net/man/3/clock_gettime
|
|
30
27
|
#
|
|
@@ -44,7 +41,7 @@ module Sidekiq
|
|
|
44
41
|
# @params element [Object]
|
|
45
42
|
# @return [ExpirableList] self
|
|
46
43
|
def <<(element)
|
|
47
|
-
@mon.synchronize { @arr << [
|
|
44
|
+
@mon.synchronize { @arr << [::Process.clock_gettime(::Process::CLOCK_MONOTONIC), element] }
|
|
48
45
|
self
|
|
49
46
|
end
|
|
50
47
|
|
|
@@ -58,7 +55,7 @@ module Sidekiq
|
|
|
58
55
|
return to_enum __method__ unless block_given?
|
|
59
56
|
|
|
60
57
|
@mon.synchronize do
|
|
61
|
-
horizon =
|
|
58
|
+
horizon = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - @ttl
|
|
62
59
|
|
|
63
60
|
# drop all elements older than horizon
|
|
64
61
|
@arr.shift while @arr[0] && @arr[0][0] < horizon
|
|
@@ -49,9 +49,14 @@ module Sidekiq
|
|
|
49
49
|
# process was terminated. It is a reverse of whatever fetcher was
|
|
50
50
|
# doing to pull the job out of queue.
|
|
51
51
|
#
|
|
52
|
+
# @param [Redis] pipelined connection for requeing via Redis#pipelined
|
|
52
53
|
# @return [void]
|
|
53
|
-
def requeue
|
|
54
|
-
|
|
54
|
+
def requeue(pipeline = nil)
|
|
55
|
+
if pipeline
|
|
56
|
+
pipeline.rpush(QueueName.expand(queue_name), job)
|
|
57
|
+
else
|
|
58
|
+
Sidekiq.redis { |conn| conn.rpush(QueueName.expand(queue_name), job) }
|
|
59
|
+
end
|
|
55
60
|
end
|
|
56
61
|
|
|
57
62
|
# Pushes job back to the head of the queue, so that job won't be tried
|
|
@@ -22,7 +22,11 @@ module Sidekiq
|
|
|
22
22
|
return if units.empty?
|
|
23
23
|
|
|
24
24
|
Sidekiq.logger.debug { "Re-queueing terminated jobs" }
|
|
25
|
-
Sidekiq.redis
|
|
25
|
+
Sidekiq.redis do |conn|
|
|
26
|
+
conn.pipelined do |pipeline|
|
|
27
|
+
units.each { |unit| unit.requeue(pipeline) }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
26
30
|
Sidekiq.logger.info("Pushed #{units.size} jobs back to Redis")
|
|
27
31
|
rescue => e
|
|
28
32
|
Sidekiq.logger.warn("Failed to requeue #{units.size} jobs: #{e}")
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# internal
|
|
4
|
+
require "sidekiq/throttled/registry"
|
|
5
|
+
|
|
6
|
+
module Sidekiq
|
|
7
|
+
module Throttled
|
|
8
|
+
# Adds helpers to your worker classes
|
|
9
|
+
#
|
|
10
|
+
# @example Usage
|
|
11
|
+
#
|
|
12
|
+
# class MyWorker
|
|
13
|
+
# include Sidekiq::Worker
|
|
14
|
+
# include Sidekiq::Throttled::Worker
|
|
15
|
+
#
|
|
16
|
+
# sidkiq_options :queue => :my_queue
|
|
17
|
+
# sidekiq_throttle :threshold => { :limit => 123, :period => 1.hour }
|
|
18
|
+
#
|
|
19
|
+
# def perform
|
|
20
|
+
# # ...
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# @see ClassMethods
|
|
25
|
+
module Job
|
|
26
|
+
# Extends worker class with {ClassMethods}.
|
|
27
|
+
#
|
|
28
|
+
# @note Using `included` hook with extending worker with {ClassMethods}
|
|
29
|
+
# in order to make API inline with `include Sidekiq::Worker`.
|
|
30
|
+
#
|
|
31
|
+
# @private
|
|
32
|
+
def self.included(worker)
|
|
33
|
+
worker.send(:extend, ClassMethods)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Helper methods added to the singleton class of destination
|
|
37
|
+
module ClassMethods
|
|
38
|
+
# Registers some strategy for the worker.
|
|
39
|
+
#
|
|
40
|
+
# @example Allow max 123 MyWorker jobs per hour
|
|
41
|
+
#
|
|
42
|
+
# class MyWorker
|
|
43
|
+
# include Sidekiq::Worker
|
|
44
|
+
# include Sidekiq::Throttled::Worker
|
|
45
|
+
#
|
|
46
|
+
# sidekiq_throttle({
|
|
47
|
+
# :threshold => { :limit => 123, :period => 1.hour }
|
|
48
|
+
# })
|
|
49
|
+
# end
|
|
50
|
+
#
|
|
51
|
+
# @example Allow max 10 concurrently running MyWorker jobs
|
|
52
|
+
#
|
|
53
|
+
# class MyWorker
|
|
54
|
+
# include Sidekiq::Worker
|
|
55
|
+
# include Sidekiq::Throttled::Worker
|
|
56
|
+
#
|
|
57
|
+
# sidekiq_throttle({
|
|
58
|
+
# :concurrency => { :limit => 10 }
|
|
59
|
+
# })
|
|
60
|
+
# end
|
|
61
|
+
#
|
|
62
|
+
# @example Allow max 10 concurrent MyWorker jobs and max 123 per hour
|
|
63
|
+
#
|
|
64
|
+
# class MyWorker
|
|
65
|
+
# include Sidekiq::Worker
|
|
66
|
+
# include Sidekiq::Throttled::Worker
|
|
67
|
+
#
|
|
68
|
+
# sidekiq_throttle({
|
|
69
|
+
# :threshold => { :limit => 123, :period => 1.hour },
|
|
70
|
+
# :concurrency => { :limit => 10 }
|
|
71
|
+
# })
|
|
72
|
+
# end
|
|
73
|
+
#
|
|
74
|
+
# @see Registry.add
|
|
75
|
+
# @return [void]
|
|
76
|
+
def sidekiq_throttle(**kwargs)
|
|
77
|
+
Registry.add(self, **kwargs)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Adds current worker to preconfigured throttling strategy. Allows
|
|
81
|
+
# sharing same pool for multiple workers.
|
|
82
|
+
#
|
|
83
|
+
# First of all we need to create shared throttling strategy:
|
|
84
|
+
#
|
|
85
|
+
# # Create google_api throttling strategy
|
|
86
|
+
# Sidekiq::Throttled::Registry.add(:google_api, {
|
|
87
|
+
# :threshold => { :limit => 123, :period => 1.hour },
|
|
88
|
+
# :concurrency => { :limit => 10 }
|
|
89
|
+
# })
|
|
90
|
+
#
|
|
91
|
+
# Now we can assign it to our workers:
|
|
92
|
+
#
|
|
93
|
+
# class FetchProfileJob
|
|
94
|
+
# include Sidekiq::Worker
|
|
95
|
+
# include Sidekiq::Throttled::Worker
|
|
96
|
+
#
|
|
97
|
+
# sidekiq_throttle_as :google_api
|
|
98
|
+
# end
|
|
99
|
+
#
|
|
100
|
+
# class FetchCommentsJob
|
|
101
|
+
# include Sidekiq::Worker
|
|
102
|
+
# include Sidekiq::Throttled::Worker
|
|
103
|
+
#
|
|
104
|
+
# sidekiq_throttle_as :google_api
|
|
105
|
+
# end
|
|
106
|
+
#
|
|
107
|
+
# With the above configuration we ensure that there are maximum 10
|
|
108
|
+
# concurrently running jobs of FetchProfileJob or FetchCommentsJob
|
|
109
|
+
# allowed. And only 123 jobs of those are executed per hour.
|
|
110
|
+
#
|
|
111
|
+
# In other words, it will allow:
|
|
112
|
+
#
|
|
113
|
+
# - only `X` concurrent `FetchProfileJob`s
|
|
114
|
+
# - max `XX` `FetchProfileJob` per hour
|
|
115
|
+
# - only `Y` concurrent `FetchCommentsJob`s
|
|
116
|
+
# - max `YY` `FetchCommentsJob` per hour
|
|
117
|
+
#
|
|
118
|
+
# Where `(X + Y) == 10` and `(XX + YY) == 123`
|
|
119
|
+
#
|
|
120
|
+
# @see Registry.add_alias
|
|
121
|
+
# @return [void]
|
|
122
|
+
def sidekiq_throttle_as(name)
|
|
123
|
+
Registry.add_alias(self, name)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -20,7 +20,7 @@ module Sidekiq
|
|
|
20
20
|
# PUSH(@key, @jid)
|
|
21
21
|
# return 0
|
|
22
22
|
# end
|
|
23
|
-
SCRIPT =
|
|
23
|
+
SCRIPT = Redis::Prescription.read "#{__dir__}/concurrency.lua"
|
|
24
24
|
private_constant :SCRIPT
|
|
25
25
|
|
|
26
26
|
# @param [#to_s] strategy_key
|
|
@@ -50,7 +50,7 @@ module Sidekiq
|
|
|
50
50
|
argv = [jid.to_s, job_limit, @ttl, Time.now.to_f]
|
|
51
51
|
|
|
52
52
|
Sidekiq.redis do |redis|
|
|
53
|
-
1 == SCRIPT.
|
|
53
|
+
1 == SCRIPT.eval(redis, :keys => keys, :argv => argv)
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -30,7 +30,7 @@ module Sidekiq
|
|
|
30
30
|
#
|
|
31
31
|
# increase!
|
|
32
32
|
# return 0
|
|
33
|
-
SCRIPT =
|
|
33
|
+
SCRIPT = Redis::Prescription.read "#{__dir__}/threshold.lua"
|
|
34
34
|
private_constant :SCRIPT
|
|
35
35
|
|
|
36
36
|
# @param [#to_s] strategy_key
|
|
@@ -67,7 +67,7 @@ module Sidekiq
|
|
|
67
67
|
argv = [job_limit, period(job_args), Time.now.to_f]
|
|
68
68
|
|
|
69
69
|
Sidekiq.redis do |redis|
|
|
70
|
-
1 == SCRIPT.
|
|
70
|
+
1 == SCRIPT.eval(redis, :keys => keys, :argv => argv)
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -37,7 +37,8 @@ module Sidekiq
|
|
|
37
37
|
percentile = 100.00 * int / max
|
|
38
38
|
lvl = if 80 <= percentile then "danger"
|
|
39
39
|
elsif 60 <= percentile then "warning"
|
|
40
|
-
else
|
|
40
|
+
else
|
|
41
|
+
"success"
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
%(<span class="label label-#{lvl}">#{int}</span>)
|
|
@@ -61,10 +62,10 @@ module Sidekiq
|
|
|
61
62
|
|
|
62
63
|
# @return [String]
|
|
63
64
|
def humanize_integer(int)
|
|
64
|
-
digits = int.to_s.
|
|
65
|
-
str = digits.shift(digits.count % 3).join
|
|
65
|
+
digits = int.to_s.chars
|
|
66
|
+
str = digits.shift(digits.count % 3).join
|
|
66
67
|
|
|
67
|
-
str << " " << digits.shift(3).join
|
|
68
|
+
str << " " << digits.shift(3).join while digits.count.positive?
|
|
68
69
|
|
|
69
70
|
str.strip
|
|
70
71
|
end
|
|
@@ -1,128 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require "sidekiq/throttled/registry"
|
|
3
|
+
require "sidekiq/throttled/job"
|
|
5
4
|
|
|
6
5
|
module Sidekiq
|
|
7
6
|
module Throttled
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
# include Sidekiq::Worker
|
|
14
|
-
# include Sidekiq::Throttled::Worker
|
|
15
|
-
#
|
|
16
|
-
# sidkiq_options :queue => :my_queue
|
|
17
|
-
# sidekiq_throttle :threshold => { :limit => 123, :period => 1.hour }
|
|
18
|
-
#
|
|
19
|
-
# def perform
|
|
20
|
-
# # ...
|
|
21
|
-
# end
|
|
22
|
-
# end
|
|
23
|
-
#
|
|
24
|
-
# @see ClassMethods
|
|
25
|
-
module Worker
|
|
26
|
-
# Extends worker class with {ClassMethods}.
|
|
27
|
-
#
|
|
28
|
-
# @note Using `included` hook with extending worker with {ClassMethods}
|
|
29
|
-
# in order to make API inline with `include Sidekiq::Worker`.
|
|
30
|
-
#
|
|
31
|
-
# @private
|
|
32
|
-
def self.included(worker)
|
|
33
|
-
worker.send(:extend, ClassMethods)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Helper methods added to the singleton class of destination
|
|
37
|
-
module ClassMethods
|
|
38
|
-
# Registers some strategy for the worker.
|
|
39
|
-
#
|
|
40
|
-
# @example Allow max 123 MyWorker jobs per hour
|
|
41
|
-
#
|
|
42
|
-
# class MyWorker
|
|
43
|
-
# include Sidekiq::Worker
|
|
44
|
-
# include Sidekiq::Throttled::Worker
|
|
45
|
-
#
|
|
46
|
-
# sidekiq_throttle({
|
|
47
|
-
# :threshold => { :limit => 123, :period => 1.hour }
|
|
48
|
-
# })
|
|
49
|
-
# end
|
|
50
|
-
#
|
|
51
|
-
# @example Allow max 10 concurrently running MyWorker jobs
|
|
52
|
-
#
|
|
53
|
-
# class MyWorker
|
|
54
|
-
# include Sidekiq::Worker
|
|
55
|
-
# include Sidekiq::Throttled::Worker
|
|
56
|
-
#
|
|
57
|
-
# sidekiq_throttle({
|
|
58
|
-
# :concurrency => { :limit => 10 }
|
|
59
|
-
# })
|
|
60
|
-
# end
|
|
61
|
-
#
|
|
62
|
-
# @example Allow max 10 concurrent MyWorker jobs and max 123 per hour
|
|
63
|
-
#
|
|
64
|
-
# class MyWorker
|
|
65
|
-
# include Sidekiq::Worker
|
|
66
|
-
# include Sidekiq::Throttled::Worker
|
|
67
|
-
#
|
|
68
|
-
# sidekiq_throttle({
|
|
69
|
-
# :threshold => { :limit => 123, :period => 1.hour },
|
|
70
|
-
# :concurrency => { :limit => 10 }
|
|
71
|
-
# })
|
|
72
|
-
# end
|
|
73
|
-
#
|
|
74
|
-
# @see Registry.add
|
|
75
|
-
# @return [void]
|
|
76
|
-
def sidekiq_throttle(**kwargs)
|
|
77
|
-
Registry.add(self, **kwargs)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# Adds current worker to preconfigured throttling strategy. Allows
|
|
81
|
-
# sharing same pool for multiple workers.
|
|
82
|
-
#
|
|
83
|
-
# First of all we need to create shared throttling strategy:
|
|
84
|
-
#
|
|
85
|
-
# # Create google_api throttling strategy
|
|
86
|
-
# Sidekiq::Throttled::Registry.add(:google_api, {
|
|
87
|
-
# :threshold => { :limit => 123, :period => 1.hour },
|
|
88
|
-
# :concurrency => { :limit => 10 }
|
|
89
|
-
# })
|
|
90
|
-
#
|
|
91
|
-
# Now we can assign it to our workers:
|
|
92
|
-
#
|
|
93
|
-
# class FetchProfileJob
|
|
94
|
-
# include Sidekiq::Worker
|
|
95
|
-
# include Sidekiq::Throttled::Worker
|
|
96
|
-
#
|
|
97
|
-
# sidekiq_throttle_as :google_api
|
|
98
|
-
# end
|
|
99
|
-
#
|
|
100
|
-
# class FetchCommentsJob
|
|
101
|
-
# include Sidekiq::Worker
|
|
102
|
-
# include Sidekiq::Throttled::Worker
|
|
103
|
-
#
|
|
104
|
-
# sidekiq_throttle_as :google_api
|
|
105
|
-
# end
|
|
106
|
-
#
|
|
107
|
-
# With the above configuration we ensure that there are maximum 10
|
|
108
|
-
# concurrently running jobs of FetchProfileJob or FetchCommentsJob
|
|
109
|
-
# allowed. And only 123 jobs of those are executed per hour.
|
|
110
|
-
#
|
|
111
|
-
# In other words, it will allow:
|
|
112
|
-
#
|
|
113
|
-
# - only `X` concurrent `FetchProfileJob`s
|
|
114
|
-
# - max `XX` `FetchProfileJob` per hour
|
|
115
|
-
# - only `Y` concurrent `FetchCommentsJob`s
|
|
116
|
-
# - max `YY` `FetchCommentsJob` per hour
|
|
117
|
-
#
|
|
118
|
-
# Where `(X + Y) == 10` and `(XX + YY) == 123`
|
|
119
|
-
#
|
|
120
|
-
# @see Registry.add_alias
|
|
121
|
-
# @return [void]
|
|
122
|
-
def sidekiq_throttle_as(name)
|
|
123
|
-
Registry.add_alias(self, name)
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
7
|
+
# A new module, Sidekiq::Job, was added in Sidekiq version 6.3.0 as a
|
|
8
|
+
# simple alias for Sidekiq::Worker as the term "worker" was considered
|
|
9
|
+
# too generic and confusing. Many people call a Sidekiq process a "worker"
|
|
10
|
+
# whereas others call the thread that executes jobs a "worker".
|
|
11
|
+
Worker = Job
|
|
127
12
|
end
|
|
128
13
|
end
|
data/lib/sidekiq/throttled.rb
CHANGED
|
@@ -9,6 +9,7 @@ require "sidekiq/throttled/communicator"
|
|
|
9
9
|
require "sidekiq/throttled/configuration"
|
|
10
10
|
require "sidekiq/throttled/queues_pauser"
|
|
11
11
|
require "sidekiq/throttled/registry"
|
|
12
|
+
require "sidekiq/throttled/job"
|
|
12
13
|
require "sidekiq/throttled/worker"
|
|
13
14
|
require "sidekiq/throttled/utils"
|
|
14
15
|
|
|
@@ -74,10 +75,11 @@ module Sidekiq
|
|
|
74
75
|
#
|
|
75
76
|
# @param [String] message Job's JSON payload
|
|
76
77
|
# @return [Boolean]
|
|
77
|
-
def throttled?(message)
|
|
78
|
+
def throttled?(message) # rubocop:disable Metrics/MethodLength
|
|
78
79
|
message = JSON.parse message
|
|
79
|
-
job = message.fetch("class")
|
|
80
|
-
|
|
80
|
+
job = message.fetch("class") { return false }
|
|
81
|
+
job = message.fetch("wrapped") { return false } if job == "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper"
|
|
82
|
+
jid = message.fetch("jid") { return false }
|
|
81
83
|
|
|
82
84
|
preload_constant! job
|
|
83
85
|
|
data/sidekiq-throttled.gemspec
CHANGED
|
@@ -8,26 +8,28 @@ require "sidekiq/throttled/version"
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
9
|
spec.name = "sidekiq-throttled"
|
|
10
10
|
spec.version = Sidekiq::Throttled::VERSION
|
|
11
|
-
spec.authors = ["Alexey
|
|
12
|
-
spec.email = ["
|
|
11
|
+
spec.authors = ["Alexey Zapparov"]
|
|
12
|
+
spec.email = ["alexey@zapparov.com"]
|
|
13
13
|
|
|
14
14
|
spec.summary = "Concurrency and threshold throttling for Sidekiq."
|
|
15
15
|
spec.description = "Concurrency and threshold throttling for Sidekiq."
|
|
16
|
-
spec.homepage = "https://github.com/
|
|
16
|
+
spec.homepage = "https://github.com/ixti/sidekiq-throttled"
|
|
17
17
|
spec.license = "MIT"
|
|
18
18
|
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
20
20
|
f.match %r{^(test|spec|features)/}
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
24
|
+
|
|
23
25
|
spec.bindir = "exe"
|
|
24
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
27
|
spec.require_paths = ["lib"]
|
|
26
28
|
|
|
27
|
-
spec.required_ruby_version = ">= 2.
|
|
29
|
+
spec.required_ruby_version = ">= 2.7"
|
|
28
30
|
|
|
29
31
|
spec.add_runtime_dependency "concurrent-ruby"
|
|
30
|
-
spec.add_runtime_dependency "redis-prescription"
|
|
32
|
+
spec.add_runtime_dependency "redis-prescription"
|
|
31
33
|
spec.add_runtime_dependency "sidekiq"
|
|
32
34
|
|
|
33
35
|
spec.add_development_dependency "bundler", ">= 2.0"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sidekiq-throttled
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.16.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Alexey
|
|
7
|
+
- Alexey Zapparov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-06-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: redis-prescription
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: sidekiq
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -68,7 +68,7 @@ dependencies:
|
|
|
68
68
|
version: '2.0'
|
|
69
69
|
description: Concurrency and threshold throttling for Sidekiq.
|
|
70
70
|
email:
|
|
71
|
-
-
|
|
71
|
+
- alexey@zapparov.com
|
|
72
72
|
executables: []
|
|
73
73
|
extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
|
@@ -78,12 +78,6 @@ files:
|
|
|
78
78
|
- ".gitignore"
|
|
79
79
|
- ".rspec"
|
|
80
80
|
- ".rubocop.yml"
|
|
81
|
-
- ".rubocop/layout.yml"
|
|
82
|
-
- ".rubocop/lint.yml"
|
|
83
|
-
- ".rubocop/metrics.yml"
|
|
84
|
-
- ".rubocop/performance.yml"
|
|
85
|
-
- ".rubocop/rspec.yml"
|
|
86
|
-
- ".rubocop/style.yml"
|
|
87
81
|
- ".rubocop_todo.yml"
|
|
88
82
|
- ".travis.yml"
|
|
89
83
|
- ".yardopts"
|
|
@@ -94,22 +88,23 @@ files:
|
|
|
94
88
|
- LICENSE.md
|
|
95
89
|
- README.md
|
|
96
90
|
- Rakefile
|
|
97
|
-
- gemfiles/sidekiq_5.0.gemfile
|
|
98
|
-
- gemfiles/sidekiq_5.1.gemfile
|
|
99
|
-
- gemfiles/sidekiq_5.2.gemfile
|
|
100
91
|
- gemfiles/sidekiq_6.0.gemfile
|
|
101
92
|
- gemfiles/sidekiq_6.1.gemfile
|
|
102
93
|
- gemfiles/sidekiq_6.2.gemfile
|
|
103
94
|
- gemfiles/sidekiq_6.3.gemfile
|
|
95
|
+
- gemfiles/sidekiq_6.4.gemfile
|
|
96
|
+
- gemfiles/sidekiq_6.5.gemfile
|
|
104
97
|
- lib/sidekiq/throttled.rb
|
|
105
98
|
- lib/sidekiq/throttled/communicator.rb
|
|
106
99
|
- lib/sidekiq/throttled/communicator/callbacks.rb
|
|
100
|
+
- lib/sidekiq/throttled/communicator/exception_handler.rb
|
|
107
101
|
- lib/sidekiq/throttled/communicator/listener.rb
|
|
108
102
|
- lib/sidekiq/throttled/configuration.rb
|
|
109
103
|
- lib/sidekiq/throttled/errors.rb
|
|
110
104
|
- lib/sidekiq/throttled/expirable_list.rb
|
|
111
105
|
- lib/sidekiq/throttled/fetch.rb
|
|
112
106
|
- lib/sidekiq/throttled/fetch/unit_of_work.rb
|
|
107
|
+
- lib/sidekiq/throttled/job.rb
|
|
113
108
|
- lib/sidekiq/throttled/middleware.rb
|
|
114
109
|
- lib/sidekiq/throttled/patches/queue.rb
|
|
115
110
|
- lib/sidekiq/throttled/queue_name.rb
|
|
@@ -132,11 +127,18 @@ files:
|
|
|
132
127
|
- lib/sidekiq/throttled/web/summary_fix.rb
|
|
133
128
|
- lib/sidekiq/throttled/web/throttled.html.erb
|
|
134
129
|
- lib/sidekiq/throttled/worker.rb
|
|
130
|
+
- rubocop/layout.yml
|
|
131
|
+
- rubocop/lint.yml
|
|
132
|
+
- rubocop/metrics.yml
|
|
133
|
+
- rubocop/performance.yml
|
|
134
|
+
- rubocop/rspec.yml
|
|
135
|
+
- rubocop/style.yml
|
|
135
136
|
- sidekiq-throttled.gemspec
|
|
136
|
-
homepage: https://github.com/
|
|
137
|
+
homepage: https://github.com/ixti/sidekiq-throttled
|
|
137
138
|
licenses:
|
|
138
139
|
- MIT
|
|
139
|
-
metadata:
|
|
140
|
+
metadata:
|
|
141
|
+
rubygems_mfa_required: 'true'
|
|
140
142
|
post_install_message:
|
|
141
143
|
rdoc_options: []
|
|
142
144
|
require_paths:
|
|
@@ -145,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
145
147
|
requirements:
|
|
146
148
|
- - ">="
|
|
147
149
|
- !ruby/object:Gem::Version
|
|
148
|
-
version: '2.
|
|
150
|
+
version: '2.7'
|
|
149
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
152
|
requirements:
|
|
151
153
|
- - ">="
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal"
|
|
6
|
-
gem "rake"
|
|
7
|
-
gem "rspec"
|
|
8
|
-
gem "rubocop", "~> 0.90.0", require: false
|
|
9
|
-
gem "rubocop-performance", "~> 1.8.0", require: false
|
|
10
|
-
gem "rubocop-rspec", "~> 1.43.2", require: false
|
|
11
|
-
gem "sidekiq", "~> 5.0.0"
|
|
12
|
-
|
|
13
|
-
group :development do
|
|
14
|
-
gem "byebug"
|
|
15
|
-
gem "guard", require: false
|
|
16
|
-
gem "guard-rspec", require: false
|
|
17
|
-
gem "guard-rubocop", require: false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
group :test do
|
|
21
|
-
gem "apparition"
|
|
22
|
-
gem "capybara"
|
|
23
|
-
gem "coveralls", require: false
|
|
24
|
-
gem "puma"
|
|
25
|
-
gem "rack-test"
|
|
26
|
-
gem "simplecov"
|
|
27
|
-
gem "sinatra"
|
|
28
|
-
gem "timecop"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
gemspec path: "../"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|