sidekiq-throttled 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +4 -0
- data/CHANGES.md +7 -0
- data/README.md +1 -0
- data/gemfiles/sidekiq_6.1.gemfile +31 -0
- data/lib/sidekiq/throttled.rb +14 -2
- data/lib/sidekiq/throttled/fetch.rb +23 -17
- data/lib/sidekiq/throttled/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b1f0237b14be26ff2b25aeaedd80e4029610cfa7c2be331827c5b865c338f48
|
4
|
+
data.tar.gz: 3a5be191a1f02b2ce21b766be820201b6f4d06b74323456412096a0beef38d11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9da0e99d328b6825ab3f47e1ea94c255717a01d05e28c90399aaf826a8d43a0e10de82baee329ddd8d846ac4e4ff0cb6f09ef11277fef2143972c50b2c3a55b
|
7
|
+
data.tar.gz: d73d011be01f319460fe87fda608aea9550e1f560bf778dfd5628874f0f074fc2020ad5e2f36ec8413a349c6dcd620f7aaa84a48f15e59dab8bf508e3e769354
|
data/Appraisals
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.13.0 (2020-07-28)
|
2
|
+
|
3
|
+
* [#85](https://github.com/sensortower/sidekiq-throttled/pull/85)
|
4
|
+
Add Sidekiq 6.1+ support.
|
5
|
+
([@hmaack])
|
6
|
+
|
1
7
|
## 0.12.0 (2020-06-22)
|
2
8
|
|
3
9
|
* [#80](https://github.com/sensortower/sidekiq-throttled/pull/80)
|
@@ -214,3 +220,4 @@
|
|
214
220
|
[@ogins57]: https://github.com/ogins57
|
215
221
|
[@lenon]: https://github.com/lenon
|
216
222
|
[@vaot]: https://github.com/vaot
|
223
|
+
[@hmaack]: https://github.com/hmaack
|
data/README.md
CHANGED
@@ -0,0 +1,31 @@
|
|
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.82.0", require: false
|
9
|
+
gem "rubocop-performance", "~>1.5.2", require: false
|
10
|
+
gem "rubocop-rspec", "~> 1.39.0", require: false
|
11
|
+
gem "sidekiq", "~> 6.1.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: "../"
|
data/lib/sidekiq/throttled.rb
CHANGED
@@ -61,8 +61,7 @@ module Sidekiq
|
|
61
61
|
QueuesPauser.instance.setup!
|
62
62
|
|
63
63
|
Sidekiq.configure_server do |config|
|
64
|
-
|
65
|
-
Sidekiq.options[:fetch] = Sidekiq::Throttled::Fetch
|
64
|
+
setup_strategy!
|
66
65
|
|
67
66
|
require "sidekiq/throttled/middleware"
|
68
67
|
config.server_middleware do |chain|
|
@@ -93,6 +92,19 @@ module Sidekiq
|
|
93
92
|
|
94
93
|
private
|
95
94
|
|
95
|
+
# @return [void]
|
96
|
+
def setup_strategy!
|
97
|
+
require "sidekiq/throttled/fetch"
|
98
|
+
|
99
|
+
# https://github.com/mperham/sidekiq/commit/fce05c9d4b4c0411c982078a4cf3a63f20f739bc
|
100
|
+
Sidekiq.options[:fetch] =
|
101
|
+
if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("6.1.0")
|
102
|
+
Sidekiq::Throttled::Fetch
|
103
|
+
else
|
104
|
+
Sidekiq::Throttled::Fetch.new(Sidekiq.options)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
96
108
|
# Tries to preload constant by it's name once.
|
97
109
|
#
|
98
110
|
# Somehow, sometimes, some classes are not eager loaded upon Rails init,
|
@@ -12,6 +12,29 @@ 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 { |conn| conn.pipelined { units.each(&:requeue) } }
|
26
|
+
Sidekiq.logger.info("Pushed #{units.size} jobs back to Redis")
|
27
|
+
rescue => e
|
28
|
+
Sidekiq.logger.warn("Failed to requeue #{units.size} jobs: #{e}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# https://github.com/mperham/sidekiq/commit/fce05c9d4b4c0411c982078a4cf3a63f20f739bc
|
33
|
+
if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("6.1.0")
|
34
|
+
extend BulkRequeue
|
35
|
+
else
|
36
|
+
include BulkRequeue
|
37
|
+
end
|
15
38
|
# Timeout to sleep between fetch retries in case of no job received,
|
16
39
|
# as well as timeout to wait for redis to give us something to work.
|
17
40
|
TIMEOUT = 2
|
@@ -50,23 +73,6 @@ module Sidekiq
|
|
50
73
|
nil
|
51
74
|
end
|
52
75
|
|
53
|
-
class << self
|
54
|
-
# Requeues all given units as a single operation.
|
55
|
-
#
|
56
|
-
# @see http://www.rubydoc.info/github/redis/redis-rb/master/Redis#pipelined-instance_method
|
57
|
-
# @param [Array<Fetch::UnitOfWork>] units
|
58
|
-
# @return [void]
|
59
|
-
def bulk_requeue(units, _options)
|
60
|
-
return if units.empty?
|
61
|
-
|
62
|
-
Sidekiq.logger.debug { "Re-queueing terminated jobs" }
|
63
|
-
Sidekiq.redis { |conn| conn.pipelined { units.each(&:requeue) } }
|
64
|
-
Sidekiq.logger.info("Pushed #{units.size} jobs back to Redis")
|
65
|
-
rescue => e
|
66
|
-
Sidekiq.logger.warn("Failed to requeue #{units.size} jobs: #{e}")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
76
|
private
|
71
77
|
|
72
78
|
# Tries to pop pair of `queue` and job `message` out of sidekiq queues.
|
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.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey V Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- gemfiles/sidekiq_5.1.gemfile
|
93
93
|
- gemfiles/sidekiq_5.2.gemfile
|
94
94
|
- gemfiles/sidekiq_6.0.gemfile
|
95
|
+
- gemfiles/sidekiq_6.1.gemfile
|
95
96
|
- lib/sidekiq/throttled.rb
|
96
97
|
- lib/sidekiq/throttled/communicator.rb
|
97
98
|
- lib/sidekiq/throttled/communicator/callbacks.rb
|
@@ -142,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
- !ruby/object:Gem::Version
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
|
-
|
146
|
-
rubygems_version: 2.7.6.2
|
146
|
+
rubygems_version: 3.1.2
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: Concurrency and threshold throttling for Sidekiq.
|