sidekiq-throttled 0.15.0 → 0.17.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/dependabot.yml +12 -0
- data/.github/workflows/ci.yml +11 -10
- data/.rubocop.yml +8 -7
- data/.rubocop_todo.yml +39 -3
- data/.travis.yml +2 -4
- data/Appraisals +4 -24
- data/CHANGES.md +44 -0
- data/Gemfile +7 -5
- data/LICENSE.md +1 -0
- data/README.md +36 -36
- data/Rakefile +1 -1
- 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/configuration.rb +4 -4
- 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 +15 -24
- data/lib/sidekiq/throttled/job.rb +128 -0
- data/lib/sidekiq/throttled/strategy/base.rb +6 -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 +12 -14
- 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}/rspec.yml +1 -1
- data/{.rubocop → rubocop}/style.yml +0 -0
- data/sidekiq-throttled.gemspec +7 -5
- metadata +22 -23
- data/gemfiles/sidekiq_5.0.gemfile +0 -31
- data/gemfiles/sidekiq_6.0.gemfile +0 -31
- data/gemfiles/sidekiq_6.1.gemfile +0 -31
- data/gemfiles/sidekiq_6.2.gemfile +0 -31
- data/gemfiles/sidekiq_6.3.gemfile +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a4884da942e03171d7265651258f4da2ca601aa36219192b325a2ce0ff113fd
|
4
|
+
data.tar.gz: 7b1d20e64db0cf3720f4b404a95744b77de186da718feb7f6abd7cd23623e08d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93699777efb1fd7794a7e566d6b129b0898f8efb327627b2a17b5e3e595a100fedc8b5a064ab8331b61c553cdd4a3aa2f3ac57c76d9d677c16ef006df18c592d
|
7
|
+
data.tar.gz: 9aaa27dbd6c116fbeac961cb8f8d1413bc1b9ff84241cfa81ce4b63b479a0b2386d6de8c94a6176a461d4f50867ce80957fd4b4569b5bd9db377d41fafbb247c
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
2
|
+
|
3
|
+
version: 2
|
4
|
+
updates:
|
5
|
+
- package-ecosystem: "github-actions"
|
6
|
+
directory: "/"
|
7
|
+
schedule:
|
8
|
+
interval: "daily"
|
9
|
+
- package-ecosystem: "bundler"
|
10
|
+
directory: "/"
|
11
|
+
schedule:
|
12
|
+
interval: "daily"
|
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.4", "6.5" ]
|
18
18
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
|
@@ -25,27 +25,28 @@ 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
|
-
- uses: actions/checkout@
|
31
|
+
- uses: actions/checkout@v3
|
32
32
|
|
33
33
|
- uses: ruby/setup-ruby@v1
|
34
34
|
with:
|
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
|
42
43
|
|
43
44
|
steps:
|
44
|
-
- uses: actions/checkout@
|
45
|
+
- uses: actions/checkout@v3
|
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/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,29 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise "sidekiq-
|
4
|
-
gem "sidekiq", "~>
|
3
|
+
appraise "sidekiq-6.4" do
|
4
|
+
gem "sidekiq", "~> 6.4.0"
|
5
5
|
end
|
6
6
|
|
7
|
-
appraise "sidekiq-5
|
8
|
-
gem "sidekiq", "~> 5.
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise "sidekiq-5.2" do
|
12
|
-
gem "sidekiq", "~> 5.2.0"
|
13
|
-
end
|
14
|
-
|
15
|
-
appraise "sidekiq-6.0" do
|
16
|
-
gem "sidekiq", "~> 6.0.0"
|
17
|
-
end
|
18
|
-
|
19
|
-
appraise "sidekiq-6.1" do
|
20
|
-
gem "sidekiq", "~> 6.1.0"
|
21
|
-
end
|
22
|
-
|
23
|
-
appraise "sidekiq-6.2" do
|
24
|
-
gem "sidekiq", "~> 6.2.0"
|
25
|
-
end
|
26
|
-
|
27
|
-
appraise "sidekiq-6.3" do
|
28
|
-
gem "sidekiq", "~> 6.3.0"
|
7
|
+
appraise "sidekiq-6.5" do
|
8
|
+
gem "sidekiq", "~> 6.5.0"
|
29
9
|
end
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,40 @@
|
|
1
|
+
## 0.16.1 (2022-06-14)
|
2
|
+
|
3
|
+
* [#2](https://github.com/ixti/sidekiq-throttled/pull/2)
|
4
|
+
Support custom ActiveJob adapters.
|
5
|
+
([@longkt90])
|
6
|
+
|
7
|
+
* [#107](https://github.com/sensortower/sidekiq-throttled/pull/107)
|
8
|
+
Log error when key sufix extraction fails.
|
9
|
+
([@pjungwir])
|
10
|
+
|
11
|
+
## 0.16.0 (2022-06-13)
|
12
|
+
|
13
|
+
* Drop Ruby 2.6 support.
|
14
|
+
|
15
|
+
* Drop Sidekiq 5.X support.
|
16
|
+
|
17
|
+
* [#121](https://github.com/sensortower/sidekiq-throttled/pull/121)
|
18
|
+
Sidekiq 6.5 compatibility.
|
19
|
+
([@hieuk09])
|
20
|
+
|
21
|
+
* [#116](https://github.com/sensortower/sidekiq-throttled/pull/116)
|
22
|
+
Unwrap ActiveJob JobWrapper
|
23
|
+
([@holstvoogd])
|
24
|
+
|
25
|
+
* [#115](https://github.com/sensortower/sidekiq-throttled/pull/115)
|
26
|
+
Fix Redis 4.6 deprecation warnings.
|
27
|
+
([@dbackeus])
|
28
|
+
|
29
|
+
* [#113](https://github.com/sensortower/sidekiq-throttled/pull/113)
|
30
|
+
Add Ruby 3.1 to CI.
|
31
|
+
([@petergoldstein])
|
32
|
+
|
33
|
+
* [#103](https://github.com/sensortower/sidekiq-throttled/pull/103)
|
34
|
+
Rename Sidekiq::Throttled::Worker to Sidekiq::Throttled::Job, and alias it
|
35
|
+
as Sidekiq::Throttled::Worker.
|
36
|
+
([@CHTJonas])
|
37
|
+
|
1
38
|
## 0.15.0 (2021-12-16)
|
2
39
|
|
3
40
|
* [#102](https://github.com/sensortower/sidekiq-throttled/pull/102)
|
@@ -254,3 +291,10 @@
|
|
254
291
|
[@mattiagiuffrida-st]: https://github.com/mattiagiuffrida-st
|
255
292
|
[@baptistejub]: https://github.com/baptistejub
|
256
293
|
[@ybiquitous]: https://github.com/ybiquitous
|
294
|
+
[@hieuk09]: https://github.com/hieuk09
|
295
|
+
[@petergoldstein]: https://github.com/petergoldstein
|
296
|
+
[@dbackeus]: https://github.com/dbackeus
|
297
|
+
[@holstvoogd]: https://github.com/holstvoogd
|
298
|
+
[@CHTJonas]: https://github.com/CHTJonas
|
299
|
+
[@pjungwir]: https://github.com/pjungwir
|
300
|
+
[@longkt90]: https://github.com/longkt90
|
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].
|
@@ -39,13 +36,13 @@ Sidekiq::Throttled.setup!
|
|
39
36
|
Load order can be an issue if you are using other Sidekiq plugins and/or middleware.
|
40
37
|
To prevent any problems, add the `.setup!` call to the bottom of your init file.
|
41
38
|
|
42
|
-
Once you've done that you can include `Sidekiq::Throttled::
|
39
|
+
Once you've done that you can include `Sidekiq::Throttled::Job` to your
|
43
40
|
job classes and configure throttling:
|
44
41
|
|
45
42
|
``` ruby
|
46
|
-
class
|
47
|
-
include Sidekiq::
|
48
|
-
include Sidekiq::Throttled::
|
43
|
+
class MyJob
|
44
|
+
include Sidekiq::Job
|
45
|
+
include Sidekiq::Throttled::Job
|
49
46
|
|
50
47
|
sidekiq_options :queue => :my_queue
|
51
48
|
|
@@ -62,15 +59,29 @@ class MyWorker
|
|
62
59
|
end
|
63
60
|
```
|
64
61
|
|
62
|
+
**NOTE:** `Sidekiq::Throttled::Job` is aliased as `Sidekiq::Throttled::Worker`,
|
63
|
+
thus if you're using Sidekiq prior 6.3.0 version, or you using `Sidekiq::Worker`
|
64
|
+
naming convention, you can use the alias for consistency:
|
65
|
+
|
66
|
+
``` ruby
|
67
|
+
class MyWorker
|
68
|
+
include Sidekiq::Worker
|
69
|
+
include Sidekiq::Throttled::Worker
|
70
|
+
|
71
|
+
# ...
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
|
65
76
|
### Observer
|
66
77
|
|
67
78
|
You can specify an observer that will be called on throttling. To do so pass an
|
68
79
|
`:observer` option with callable object:
|
69
80
|
|
70
81
|
``` ruby
|
71
|
-
class
|
72
|
-
include Sidekiq::
|
73
|
-
include Sidekiq::Throttled::
|
82
|
+
class MyJob
|
83
|
+
include Sidekiq::Job
|
84
|
+
include Sidekiq::Throttled::Job
|
74
85
|
|
75
86
|
MY_OBSERVER = lambda do |strategy, *args|
|
76
87
|
# do something
|
@@ -100,9 +111,9 @@ to the job.
|
|
100
111
|
You can throttle jobs dynamically with `:key_suffix` option:
|
101
112
|
|
102
113
|
``` ruby
|
103
|
-
class
|
104
|
-
include Sidekiq::
|
105
|
-
include Sidekiq::Throttled::
|
114
|
+
class MyJob
|
115
|
+
include Sidekiq::Job
|
116
|
+
include Sidekiq::Throttled::Job
|
106
117
|
|
107
118
|
sidekiq_options :queue => :my_queue
|
108
119
|
|
@@ -122,9 +133,9 @@ for these values. The proc will be evaluated at the time the job is fetched
|
|
122
133
|
and will receive the same arguments that are passed to the job.
|
123
134
|
|
124
135
|
``` ruby
|
125
|
-
class
|
126
|
-
include Sidekiq::
|
127
|
-
include Sidekiq::Throttled::
|
136
|
+
class MyJob
|
137
|
+
include Sidekiq::Job
|
138
|
+
include Sidekiq::Throttled::Job
|
128
139
|
|
129
140
|
sidekiq_options :queue => :my_queue
|
130
141
|
|
@@ -150,9 +161,9 @@ end
|
|
150
161
|
You also can use several different keys to throttle one worker.
|
151
162
|
|
152
163
|
``` ruby
|
153
|
-
class
|
154
|
-
include Sidekiq::
|
155
|
-
include Sidekiq::Throttled::
|
164
|
+
class MyJob
|
165
|
+
include Sidekiq::Job
|
166
|
+
include Sidekiq::Throttled::Job
|
156
167
|
|
157
168
|
sidekiq_options :queue => :my_queue
|
158
169
|
|
@@ -230,12 +241,12 @@ end
|
|
230
241
|
|
231
242
|
## Supported Ruby Versions
|
232
243
|
|
233
|
-
This library aims to support and is [tested against][
|
244
|
+
This library aims to support and is [tested against][ci] the following Ruby
|
234
245
|
versions:
|
235
246
|
|
236
|
-
* Ruby 2.6.x
|
237
247
|
* Ruby 2.7.x
|
238
248
|
* Ruby 3.0.x
|
249
|
+
* Ruby 3.1.x
|
239
250
|
|
240
251
|
If something doesn't work on one of these versions, it's a bug.
|
241
252
|
|
@@ -255,13 +266,8 @@ dropped.
|
|
255
266
|
|
256
267
|
This library aims to support work with following [Sidekiq][sidekiq] versions:
|
257
268
|
|
258
|
-
* Sidekiq
|
259
|
-
* Sidekiq 5.
|
260
|
-
* Sidekiq 5.2.x
|
261
|
-
* Sidekiq 6.0.x
|
262
|
-
* Sidekiq 6.1.x
|
263
|
-
* Sidekiq 6.2.x
|
264
|
-
* Sidekiq 6.3.x
|
269
|
+
* Sidekiq 6.4.x
|
270
|
+
* Sidekiq 6.5.x
|
265
271
|
|
266
272
|
|
267
273
|
## Contributing
|
@@ -287,11 +293,5 @@ bundle exec rubocop # run static code analysis
|
|
287
293
|
Don't forget to run `appraisal update` after any changes to `Gemfile`.
|
288
294
|
|
289
295
|
|
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
|
296
|
+
[ci]: https://github.com/ixti/sidekiq-throttled/actions/workflows/ci.yml
|
297
297
|
[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,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
|
@@ -21,14 +21,14 @@ module Sidekiq
|
|
21
21
|
# Instructs throttler to lookup strategies in parent classes, if there's
|
22
22
|
# no own strategy:
|
23
23
|
#
|
24
|
-
# class
|
25
|
-
# include Sidekiq::
|
26
|
-
# include Sidekiq::
|
24
|
+
# class FooJob
|
25
|
+
# include Sidekiq::Job
|
26
|
+
# include Sidekiq::Throttled::Job
|
27
27
|
#
|
28
28
|
# sidekiq_throttle :concurrency => { :limit => 42 }
|
29
29
|
# end
|
30
30
|
#
|
31
|
-
# class
|
31
|
+
# class BarJob < FooJob
|
32
32
|
# end
|
33
33
|
#
|
34
34
|
# By default in the example above, `Bar` won't have throttling options.
|
@@ -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
|