sidekiq-throttled 0.16.2 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.travis.yml +2 -4
- data/Appraisals +0 -16
- data/CHANGES.md +18 -0
- data/README.md +0 -4
- data/lib/sidekiq/throttled/fetch.rb +15 -28
- data/lib/sidekiq/throttled/strategy/concurrency.rb +3 -3
- data/lib/sidekiq/throttled/strategy/threshold.rb +3 -3
- data/lib/sidekiq/throttled/version.rb +1 -1
- data/lib/sidekiq/throttled.rb +3 -11
- data/sidekiq-throttled.gemspec +2 -2
- metadata +11 -15
- data/gemfiles/sidekiq_6.0.gemfile +0 -33
- data/gemfiles/sidekiq_6.1.gemfile +0 -33
- data/gemfiles/sidekiq_6.2.gemfile +0 -33
- data/gemfiles/sidekiq_6.3.gemfile +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9709e5805bd1bf11ef204afb08a988a4c5998e16ecf8a7a0b8e0c1b4b753ce4d
|
4
|
+
data.tar.gz: 21b5bdd50945f807e11884a18449be0155cb8bdf2b6ee37b633148b198db615d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613164a091883655c4bd879b3dab25198ffc88e49eb7f1e1b0bab33eb2a7eb004b2f6d407e65ccfea52727e347f1b5d8c05015117b5da8500a2a933228044ef4
|
7
|
+
data.tar.gz: 9b2dde3fd9ecdf25301597bd86609f531f7a8b5d8a90833f7f0d42399501a3d49252fa78af3cc576007cdf8b7025b86223c1a9d1391ab9069c6277220adb7524
|
data/.github/workflows/ci.yml
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise "sidekiq-6.0" do
|
4
|
-
gem "sidekiq", "~> 6.0.0"
|
5
|
-
end
|
6
|
-
|
7
|
-
appraise "sidekiq-6.1" do
|
8
|
-
gem "sidekiq", "~> 6.1.0"
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise "sidekiq-6.2" do
|
12
|
-
gem "sidekiq", "~> 6.2.0"
|
13
|
-
end
|
14
|
-
|
15
|
-
appraise "sidekiq-6.3" do
|
16
|
-
gem "sidekiq", "~> 6.3.0"
|
17
|
-
end
|
18
|
-
|
19
3
|
appraise "sidekiq-6.4" do
|
20
4
|
gem "sidekiq", "~> 6.4.0"
|
21
5
|
end
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 0.18.0 (2023-04-10)
|
2
|
+
|
3
|
+
* Fix redis-prescription dependency usage
|
4
|
+
|
5
|
+
## 0.17.0 (2022-09-14)
|
6
|
+
|
7
|
+
* [#13](https://github.com/ixti/sidekiq-throttled/pull/13)
|
8
|
+
Fix redis-4.8+ deprecation warnings
|
9
|
+
|
10
|
+
* [#8](https://github.com/ixti/sidekiq-throttled/pull/8)
|
11
|
+
Drop Sidekiq < 6.4 support
|
12
|
+
|
13
|
+
## 0.16.2 (2022-07-19)
|
14
|
+
|
15
|
+
* [#5](https://github.com/ixti/sidekiq-throttled/issues/5)
|
16
|
+
[#6](https://github.com/ixti/sidekiq-throttled/pull/6)
|
17
|
+
Add Sidekiq 6.5+ support
|
18
|
+
|
1
19
|
## 0.16.1 (2022-06-14)
|
2
20
|
|
3
21
|
* [#2](https://github.com/ixti/sidekiq-throttled/pull/2)
|
data/README.md
CHANGED
@@ -12,33 +12,6 @@ module Sidekiq
|
|
12
12
|
#
|
13
13
|
# @private
|
14
14
|
class Fetch
|
15
|
-
module BulkRequeue
|
16
|
-
# Requeues all given units as a single operation.
|
17
|
-
#
|
18
|
-
# @see http://www.rubydoc.info/github/redis/redis-rb/master/Redis#pipelined-instance_method
|
19
|
-
# @param [Array<Fetch::UnitOfWork>] units
|
20
|
-
# @return [void]
|
21
|
-
def bulk_requeue(units, _options)
|
22
|
-
return if units.empty?
|
23
|
-
|
24
|
-
Sidekiq.logger.debug { "Re-queueing terminated jobs" }
|
25
|
-
Sidekiq.redis do |conn|
|
26
|
-
conn.pipelined do |pipeline|
|
27
|
-
units.each { |unit| unit.requeue(pipeline) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
Sidekiq.logger.info("Pushed #{units.size} jobs back to Redis")
|
31
|
-
rescue => e
|
32
|
-
Sidekiq.logger.warn("Failed to requeue #{units.size} jobs: #{e}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# https://github.com/mperham/sidekiq/commit/fce05c9d4b4c0411c982078a4cf3a63f20f739bc
|
37
|
-
if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("6.1.0")
|
38
|
-
extend BulkRequeue
|
39
|
-
else
|
40
|
-
include BulkRequeue
|
41
|
-
end
|
42
15
|
# Timeout to sleep between fetch retries in case of no job received,
|
43
16
|
# as well as timeout to wait for redis to give us something to work.
|
44
17
|
TIMEOUT = 2
|
@@ -77,6 +50,20 @@ module Sidekiq
|
|
77
50
|
nil
|
78
51
|
end
|
79
52
|
|
53
|
+
def bulk_requeue(units, _options)
|
54
|
+
return if units.empty?
|
55
|
+
|
56
|
+
Sidekiq.logger.debug { "Re-queueing terminated jobs" }
|
57
|
+
Sidekiq.redis do |conn|
|
58
|
+
conn.pipelined do |pipeline|
|
59
|
+
units.each { |unit| unit.requeue(pipeline) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
Sidekiq.logger.info("Pushed #{units.size} jobs back to Redis")
|
63
|
+
rescue => e
|
64
|
+
Sidekiq.logger.warn("Failed to requeue #{units.size} jobs: #{e}")
|
65
|
+
end
|
66
|
+
|
80
67
|
private
|
81
68
|
|
82
69
|
# Tries to pop pair of `queue` and job `message` out of sidekiq queues.
|
@@ -91,7 +78,7 @@ module Sidekiq
|
|
91
78
|
return
|
92
79
|
end
|
93
80
|
|
94
|
-
Sidekiq.redis { |conn| conn.brpop(*queues, TIMEOUT) }
|
81
|
+
Sidekiq.redis { |conn| conn.brpop(*queues, :timeout => TIMEOUT) }
|
95
82
|
end
|
96
83
|
|
97
84
|
# Returns list of queues to try to fetch jobs from.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "redis_prescription"
|
4
4
|
|
5
5
|
require "sidekiq/throttled/strategy/base"
|
6
6
|
|
@@ -20,7 +20,7 @@ module Sidekiq
|
|
20
20
|
# PUSH(@key, @jid)
|
21
21
|
# return 0
|
22
22
|
# end
|
23
|
-
SCRIPT =
|
23
|
+
SCRIPT = RedisPrescription.new(File.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.call(redis, :keys => keys, :argv => argv)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "redis_prescription"
|
4
4
|
|
5
5
|
require "sidekiq/throttled/strategy/base"
|
6
6
|
|
@@ -30,7 +30,7 @@ module Sidekiq
|
|
30
30
|
#
|
31
31
|
# increase!
|
32
32
|
# return 0
|
33
|
-
SCRIPT =
|
33
|
+
SCRIPT = RedisPrescription.new(File.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.call(redis, :keys => keys, :argv => argv)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/lib/sidekiq/throttled.rb
CHANGED
@@ -97,18 +97,10 @@ module Sidekiq
|
|
97
97
|
def setup_strategy!(sidekiq_config)
|
98
98
|
require "sidekiq/throttled/fetch"
|
99
99
|
|
100
|
-
sidekiq_version = Gem::Version.new(Sidekiq::VERSION)
|
101
|
-
|
102
100
|
# https://github.com/mperham/sidekiq/commit/67daa7a408b214d593100f782271ed108686c147
|
103
|
-
sidekiq_config = sidekiq_config.options if
|
104
|
-
|
105
|
-
|
106
|
-
sidekiq_config[:fetch] =
|
107
|
-
if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("6.1.0")
|
108
|
-
Sidekiq::Throttled::Fetch
|
109
|
-
else
|
110
|
-
Sidekiq::Throttled::Fetch.new(sidekiq_config)
|
111
|
-
end
|
101
|
+
sidekiq_config = sidekiq_config.options if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("6.5.0")
|
102
|
+
|
103
|
+
sidekiq_config[:fetch] = Sidekiq::Throttled::Fetch.new(sidekiq_config)
|
112
104
|
end
|
113
105
|
|
114
106
|
# Tries to preload constant by it's name once.
|
data/sidekiq-throttled.gemspec
CHANGED
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.required_ruby_version = ">= 2.7"
|
30
30
|
|
31
31
|
spec.add_runtime_dependency "concurrent-ruby"
|
32
|
-
spec.add_runtime_dependency "redis-prescription"
|
33
|
-
spec.add_runtime_dependency "sidekiq"
|
32
|
+
spec.add_runtime_dependency "redis-prescription", "~> 2.2"
|
33
|
+
spec.add_runtime_dependency "sidekiq", "~> 6.4"
|
34
34
|
|
35
35
|
spec.add_development_dependency "bundler", ">= 2.0"
|
36
36
|
end
|
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.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -28,30 +28,30 @@ 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: '2.2'
|
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: '2.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sidekiq
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '6.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '6.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,10 +89,6 @@ files:
|
|
89
89
|
- LICENSE.md
|
90
90
|
- README.md
|
91
91
|
- Rakefile
|
92
|
-
- gemfiles/sidekiq_6.0.gemfile
|
93
|
-
- gemfiles/sidekiq_6.1.gemfile
|
94
|
-
- gemfiles/sidekiq_6.2.gemfile
|
95
|
-
- gemfiles/sidekiq_6.3.gemfile
|
96
92
|
- gemfiles/sidekiq_6.4.gemfile
|
97
93
|
- gemfiles/sidekiq_6.5.gemfile
|
98
94
|
- lib/sidekiq/throttled.rb
|
@@ -155,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
151
|
- !ruby/object:Gem::Version
|
156
152
|
version: '0'
|
157
153
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.3.26
|
159
155
|
signing_key:
|
160
156
|
specification_version: 4
|
161
157
|
summary: Concurrency and threshold throttling for Sidekiq.
|
@@ -1,33 +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 "sidekiq", "~> 6.0.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "byebug"
|
12
|
-
gem "guard", require: false
|
13
|
-
gem "guard-rspec", require: false
|
14
|
-
gem "guard-rubocop", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
group :test do
|
18
|
-
gem "apparition"
|
19
|
-
gem "capybara"
|
20
|
-
gem "puma"
|
21
|
-
gem "rack-test"
|
22
|
-
gem "sinatra"
|
23
|
-
gem "timecop"
|
24
|
-
end
|
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
|
-
|
33
|
-
gemspec path: "../"
|
@@ -1,33 +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 "sidekiq", "~> 6.1.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "byebug"
|
12
|
-
gem "guard", require: false
|
13
|
-
gem "guard-rspec", require: false
|
14
|
-
gem "guard-rubocop", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
group :test do
|
18
|
-
gem "apparition"
|
19
|
-
gem "capybara"
|
20
|
-
gem "puma"
|
21
|
-
gem "rack-test"
|
22
|
-
gem "sinatra"
|
23
|
-
gem "timecop"
|
24
|
-
end
|
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
|
-
|
33
|
-
gemspec path: "../"
|
@@ -1,33 +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 "sidekiq", "~> 6.2.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "byebug"
|
12
|
-
gem "guard", require: false
|
13
|
-
gem "guard-rspec", require: false
|
14
|
-
gem "guard-rubocop", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
group :test do
|
18
|
-
gem "apparition"
|
19
|
-
gem "capybara"
|
20
|
-
gem "puma"
|
21
|
-
gem "rack-test"
|
22
|
-
gem "sinatra"
|
23
|
-
gem "timecop"
|
24
|
-
end
|
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
|
-
|
33
|
-
gemspec path: "../"
|
@@ -1,33 +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 "sidekiq", "~> 6.3.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "byebug"
|
12
|
-
gem "guard", require: false
|
13
|
-
gem "guard-rspec", require: false
|
14
|
-
gem "guard-rubocop", require: false
|
15
|
-
end
|
16
|
-
|
17
|
-
group :test do
|
18
|
-
gem "apparition"
|
19
|
-
gem "capybara"
|
20
|
-
gem "puma"
|
21
|
-
gem "rack-test"
|
22
|
-
gem "sinatra"
|
23
|
-
gem "timecop"
|
24
|
-
end
|
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
|
-
|
33
|
-
gemspec path: "../"
|