sidekiq-throttled 0.8.2 → 0.9.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/.rubocop.yml +11 -13
- data/.rubocop_todo.yml +57 -0
- data/.travis.yml +5 -22
- data/Appraisals +4 -12
- data/CHANGES.md +13 -0
- data/Gemfile +3 -2
- data/LICENSE.md +1 -1
- data/README.md +3 -5
- data/gemfiles/sidekiq_5.0.gemfile +3 -2
- data/gemfiles/sidekiq_5.1.gemfile +3 -2
- data/gemfiles/{sidekiq_4.0.gemfile → sidekiq_5.2.gemfile} +4 -3
- data/lib/sidekiq/throttled.rb +0 -3
- data/lib/sidekiq/throttled/communicator.rb +2 -3
- data/lib/sidekiq/throttled/communicator/callbacks.rb +0 -1
- data/lib/sidekiq/throttled/communicator/listener.rb +1 -1
- data/lib/sidekiq/throttled/queue_name.rb +4 -4
- data/lib/sidekiq/throttled/strategy.rb +7 -7
- data/lib/sidekiq/throttled/version.rb +1 -1
- data/lib/sidekiq/throttled/web.rb +2 -2
- data/lib/sidekiq/throttled/web/stats.rb +6 -3
- data/lib/sidekiq/throttled/web/summary_fix.js +10 -0
- data/lib/sidekiq/throttled/web/summary_fix.rb +13 -6
- data/sidekiq-throttled.gemspec +3 -2
- metadata +21 -9
- data/.rubocop.todo.yml +0 -25
- data/gemfiles/sidekiq_4.1.gemfile +0 -29
- data/gemfiles/sidekiq_4.2.gemfile +0 -29
- data/lib/sidekiq/throttled/web/summary_fix.html +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc7a98ab5bb314051a1771f82401d9eb0f33e976434a61ec2851f4b3cb653e15
|
|
4
|
+
data.tar.gz: a04d5ca0da17d9c49f5fea46763d622b81e20cd3f43d1431902b901670bfe45c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b25afcecde886729c0e5519145bf3d796ba1cd6a77b2904cfb1203327b93b14f0a55768980ee83b6b7c7f8cb699a774c6a0842cf5d7e9fbddf22461b955ed01
|
|
7
|
+
data.tar.gz: 0bb94625ae6f48229eaa8199b8a20af455910c6bb8b34c983af014e159f6d737bb2c210eba57fb53e58c7e729fa74d28413868805c63e53535c9ad5df9c83dcd
|
data/.rubocop.yml
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
inherit_from:
|
|
1
|
+
inherit_from:
|
|
2
|
+
- .rubocop_todo.yml
|
|
3
|
+
|
|
4
|
+
require:
|
|
5
|
+
- rubocop-rspec
|
|
2
6
|
|
|
3
7
|
################################################################################
|
|
4
8
|
|
|
5
9
|
AllCops:
|
|
6
10
|
DisplayCopNames: true
|
|
7
|
-
TargetRubyVersion: 2.
|
|
11
|
+
TargetRubyVersion: 2.3
|
|
12
|
+
Exclude:
|
|
13
|
+
- "gemfiles/*"
|
|
8
14
|
|
|
9
15
|
## Layout ######################################################################
|
|
10
16
|
|
|
@@ -26,14 +32,6 @@ Layout/MultilineMethodCallIndentation:
|
|
|
26
32
|
Layout/SpaceInLambdaLiteral:
|
|
27
33
|
EnforcedStyle: require_space
|
|
28
34
|
|
|
29
|
-
## Layout ######################################################################
|
|
30
|
-
|
|
31
|
-
# Adds useless noise. I would prefer it to enforce blind rescues instead of
|
|
32
|
-
# rescue from StandardError. To me blind rescue is as natural as implicit
|
|
33
|
-
# return.
|
|
34
|
-
Lint/RescueWithoutErrorClass:
|
|
35
|
-
Enabled: false
|
|
36
|
-
|
|
37
35
|
## Metrics #####################################################################
|
|
38
36
|
|
|
39
37
|
Metrics/BlockLength:
|
|
@@ -49,9 +47,6 @@ Style/BracesAroundHashParameters:
|
|
|
49
47
|
Style/Documentation:
|
|
50
48
|
Enabled: false
|
|
51
49
|
|
|
52
|
-
Style/Encoding:
|
|
53
|
-
EnforcedStyle: when_needed
|
|
54
|
-
|
|
55
50
|
Style/HashSyntax:
|
|
56
51
|
EnforcedStyle: hash_rockets
|
|
57
52
|
|
|
@@ -68,6 +63,9 @@ Style/Lambda:
|
|
|
68
63
|
Style/RegexpLiteral:
|
|
69
64
|
Enabled: false
|
|
70
65
|
|
|
66
|
+
Style/RescueStandardError:
|
|
67
|
+
EnforcedStyle: implicit
|
|
68
|
+
|
|
71
69
|
Style/StringLiterals:
|
|
72
70
|
EnforcedStyle: double_quotes
|
|
73
71
|
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2018-09-10 23:47:55 +0000 using RuboCop version 0.58.2.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 5
|
|
10
|
+
# Configuration parameters: CountComments.
|
|
11
|
+
Metrics/MethodLength:
|
|
12
|
+
Max: 13
|
|
13
|
+
|
|
14
|
+
# Offense count: 25
|
|
15
|
+
# Configuration parameters: Max.
|
|
16
|
+
RSpec/ExampleLength:
|
|
17
|
+
Exclude:
|
|
18
|
+
- 'spec/sidekiq/throttled/communicator/callbacks_spec.rb'
|
|
19
|
+
- 'spec/sidekiq/throttled/communicator/listener_spec.rb'
|
|
20
|
+
- 'spec/sidekiq/throttled/communicator_spec.rb'
|
|
21
|
+
- 'spec/sidekiq/throttled/fetch_spec.rb'
|
|
22
|
+
- 'spec/sidekiq/throttled/queues_pauser_spec.rb'
|
|
23
|
+
- 'spec/sidekiq/throttled/strategy_spec.rb'
|
|
24
|
+
- 'spec/sidekiq/throttled/web/queues_spec.rb'
|
|
25
|
+
- 'spec/sidekiq/throttled_spec.rb'
|
|
26
|
+
|
|
27
|
+
# Offense count: 62
|
|
28
|
+
# Configuration parameters: .
|
|
29
|
+
# SupportedStyles: have_received, receive
|
|
30
|
+
RSpec/MessageSpies:
|
|
31
|
+
EnforcedStyle: receive
|
|
32
|
+
|
|
33
|
+
# Offense count: 20
|
|
34
|
+
# Configuration parameters: AggregateFailuresByDefault.
|
|
35
|
+
RSpec/MultipleExpectations:
|
|
36
|
+
Max: 4
|
|
37
|
+
|
|
38
|
+
# Offense count: 33
|
|
39
|
+
RSpec/NestedGroups:
|
|
40
|
+
Max: 5
|
|
41
|
+
|
|
42
|
+
# Offense count: 3
|
|
43
|
+
RSpec/SubjectStub:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'spec/sidekiq/throttled/communicator_spec.rb'
|
|
46
|
+
- 'spec/sidekiq/throttled/queues_pauser_spec.rb'
|
|
47
|
+
|
|
48
|
+
# Offense count: 1
|
|
49
|
+
# Configuration parameters: IgnoreSymbolicNames.
|
|
50
|
+
RSpec/VerifiedDoubles:
|
|
51
|
+
Exclude:
|
|
52
|
+
- 'spec/sidekiq/throttled/registry_spec.rb'
|
|
53
|
+
|
|
54
|
+
# Offense count: 1
|
|
55
|
+
Security/MarshalLoad:
|
|
56
|
+
Exclude:
|
|
57
|
+
- 'lib/sidekiq/throttled/communicator/listener.rb'
|
data/.travis.yml
CHANGED
|
@@ -18,37 +18,20 @@ before_install:
|
|
|
18
18
|
|
|
19
19
|
install: bundle install --without development
|
|
20
20
|
|
|
21
|
-
env:
|
|
22
|
-
- WITH_REDIS_NAMESPACE="false"
|
|
23
|
-
- WITH_REDIS_NAMESPACE="true"
|
|
24
|
-
|
|
25
21
|
rvm:
|
|
26
|
-
- 2.
|
|
27
|
-
- 2.
|
|
28
|
-
- 2.
|
|
22
|
+
- 2.3
|
|
23
|
+
- 2.4
|
|
24
|
+
- 2.5
|
|
29
25
|
|
|
30
26
|
matrix:
|
|
31
27
|
fast_finish: true
|
|
32
28
|
include:
|
|
33
29
|
-
|
|
34
|
-
rvm: 2.
|
|
30
|
+
rvm: 2.3
|
|
35
31
|
env: SUITE="rubocop"
|
|
36
32
|
gemfile: Gemfile
|
|
37
|
-
-
|
|
38
|
-
rvm: jruby-9.1.8.0
|
|
39
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug" WITH_REDIS_NAMESPACE="false"
|
|
40
|
-
gemfile: Gemfile
|
|
41
|
-
-
|
|
42
|
-
rvm: jruby-9.1.8.0
|
|
43
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug" WITH_REDIS_NAMESPACE="true"
|
|
44
|
-
gemfile: Gemfile
|
|
45
|
-
allow_failures:
|
|
46
|
-
-
|
|
47
|
-
rvm: jruby-9.1.8.0
|
|
48
33
|
|
|
49
34
|
gemfile:
|
|
50
|
-
- gemfiles/sidekiq_4.0.gemfile
|
|
51
|
-
- gemfiles/sidekiq_4.1.gemfile
|
|
52
|
-
- gemfiles/sidekiq_4.2.gemfile
|
|
53
35
|
- gemfiles/sidekiq_5.0.gemfile
|
|
54
36
|
- gemfiles/sidekiq_5.1.gemfile
|
|
37
|
+
- gemfiles/sidekiq_5.2.gemfile
|
data/Appraisals
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
appraise "sidekiq-4.0" do
|
|
4
|
-
gem "sidekiq", "~> 4.0.0"
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
appraise "sidekiq-4.1" do
|
|
8
|
-
gem "sidekiq", "~> 4.1.0"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
appraise "sidekiq-4.2" do
|
|
12
|
-
gem "sidekiq", "~> 4.2.0"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
3
|
appraise "sidekiq-5.0" do
|
|
16
4
|
gem "sidekiq", "~> 5.0.0"
|
|
17
5
|
end
|
|
@@ -19,3 +7,7 @@ end
|
|
|
19
7
|
appraise "sidekiq-5.1" do
|
|
20
8
|
gem "sidekiq", "~> 5.1.0"
|
|
21
9
|
end
|
|
10
|
+
|
|
11
|
+
appraise "sidekiq-5.2" do
|
|
12
|
+
gem "sidekiq", "~> 5.2.0"
|
|
13
|
+
end
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 0.9.9 (2018-09-11)
|
|
2
|
+
|
|
3
|
+
* Add support of Sidekiq 5.2.x
|
|
4
|
+
([@ixti])
|
|
5
|
+
|
|
6
|
+
* Drop support of Sidekiq 4.x
|
|
7
|
+
([@ixti])
|
|
8
|
+
|
|
9
|
+
* Add concurrent-ruby as dependency which is no longer a dependency of
|
|
10
|
+
Sidekiq as 5.2+ version.
|
|
11
|
+
([@ixti])
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## 0.8.2 (2018-02-14)
|
|
2
15
|
|
|
3
16
|
* Extract redis LUA scripts stored procedures runner to redis-prescription gem.
|
data/Gemfile
CHANGED
|
@@ -4,9 +4,9 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
|
-
gem "redis-namespace", :require => false
|
|
8
7
|
gem "rspec"
|
|
9
|
-
gem "rubocop",
|
|
8
|
+
gem "rubocop", "~> 0.58.0", :require => false
|
|
9
|
+
gem "rubocop-rspec", "~> 1.29.1", :require => false
|
|
10
10
|
gem "sidekiq"
|
|
11
11
|
|
|
12
12
|
group :development do
|
|
@@ -20,6 +20,7 @@ group :test do
|
|
|
20
20
|
gem "capybara"
|
|
21
21
|
gem "coveralls", :require => false
|
|
22
22
|
gem "poltergeist"
|
|
23
|
+
gem "puma"
|
|
23
24
|
gem "rack-test"
|
|
24
25
|
gem "simplecov", ">= 0.9"
|
|
25
26
|
gem "sinatra", "~> 1.4", ">= 1.4.6"
|
data/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2015-
|
|
3
|
+
Copyright (c) 2015-2018 SensorTower Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -155,9 +155,9 @@ end
|
|
|
155
155
|
This library aims to support and is [tested against][travis] the following Ruby
|
|
156
156
|
versions:
|
|
157
157
|
|
|
158
|
-
* Ruby 2.2.6+
|
|
159
158
|
* Ruby 2.3.x
|
|
160
159
|
* Ruby 2.4.x
|
|
160
|
+
* Ruby 2.5.x
|
|
161
161
|
|
|
162
162
|
If something doesn't work on one of these versions, it's a bug.
|
|
163
163
|
|
|
@@ -177,11 +177,9 @@ dropped.
|
|
|
177
177
|
|
|
178
178
|
This library aims to support work with following [Sidekiq][sidekiq] versions:
|
|
179
179
|
|
|
180
|
-
* Sidekiq 4.0.x
|
|
181
|
-
* Sidekiq 4.1.x
|
|
182
|
-
* Sidekiq 4.2.x
|
|
183
180
|
* Sidekiq 5.0.x
|
|
184
181
|
* Sidekiq 5.1.x
|
|
182
|
+
* Sidekiq 5.2.x
|
|
185
183
|
|
|
186
184
|
|
|
187
185
|
## Contributing
|
|
@@ -209,7 +207,7 @@ Don't forget to run `appraisal update` after any changes to `Gemfile`.
|
|
|
209
207
|
|
|
210
208
|
## Copyright
|
|
211
209
|
|
|
212
|
-
Copyright (c) 2015-
|
|
210
|
+
Copyright (c) 2015-2018 SensorTower Inc.
|
|
213
211
|
See LICENSE.md for further details.
|
|
214
212
|
|
|
215
213
|
|
|
@@ -4,9 +4,9 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
|
-
gem "redis-namespace", require: false
|
|
8
7
|
gem "rspec"
|
|
9
|
-
gem "rubocop", "~> 0.
|
|
8
|
+
gem "rubocop", "~> 0.58.0", require: false
|
|
9
|
+
gem "rubocop-rspec", "~> 1.29.1", require: false
|
|
10
10
|
gem "sidekiq", "~> 5.0.0"
|
|
11
11
|
|
|
12
12
|
group :development do
|
|
@@ -20,6 +20,7 @@ group :test do
|
|
|
20
20
|
gem "capybara"
|
|
21
21
|
gem "coveralls", require: false
|
|
22
22
|
gem "poltergeist"
|
|
23
|
+
gem "puma"
|
|
23
24
|
gem "rack-test"
|
|
24
25
|
gem "simplecov", ">= 0.9"
|
|
25
26
|
gem "sinatra", "~> 1.4", ">= 1.4.6"
|
|
@@ -4,9 +4,9 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
|
-
gem "redis-namespace", require: false
|
|
8
7
|
gem "rspec"
|
|
9
|
-
gem "rubocop", "~> 0.
|
|
8
|
+
gem "rubocop", "~> 0.58.0", require: false
|
|
9
|
+
gem "rubocop-rspec", "~> 1.29.1", require: false
|
|
10
10
|
gem "sidekiq", "~> 5.1.0"
|
|
11
11
|
|
|
12
12
|
group :development do
|
|
@@ -20,6 +20,7 @@ group :test do
|
|
|
20
20
|
gem "capybara"
|
|
21
21
|
gem "coveralls", require: false
|
|
22
22
|
gem "poltergeist"
|
|
23
|
+
gem "puma"
|
|
23
24
|
gem "rack-test"
|
|
24
25
|
gem "simplecov", ">= 0.9"
|
|
25
26
|
gem "sinatra", "~> 1.4", ">= 1.4.6"
|
|
@@ -4,10 +4,10 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
gem "rake"
|
|
7
|
-
gem "redis-namespace", require: false
|
|
8
7
|
gem "rspec"
|
|
9
|
-
gem "rubocop", "~> 0.
|
|
10
|
-
gem "
|
|
8
|
+
gem "rubocop", "~> 0.58.0", require: false
|
|
9
|
+
gem "rubocop-rspec", "~> 1.29.1", require: false
|
|
10
|
+
gem "sidekiq", "~> 5.2.0"
|
|
11
11
|
|
|
12
12
|
group :development do
|
|
13
13
|
gem "byebug"
|
|
@@ -20,6 +20,7 @@ group :test do
|
|
|
20
20
|
gem "capybara"
|
|
21
21
|
gem "coveralls", require: false
|
|
22
22
|
gem "poltergeist"
|
|
23
|
+
gem "puma"
|
|
23
24
|
gem "rack-test"
|
|
24
25
|
gem "simplecov", ">= 0.9"
|
|
25
26
|
gem "sinatra", "~> 1.4", ">= 1.4.6"
|
data/lib/sidekiq/throttled.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "thread"
|
|
4
3
|
require "singleton"
|
|
5
4
|
|
|
6
5
|
require "sidekiq/exception_handler"
|
|
@@ -54,7 +53,7 @@ module Sidekiq
|
|
|
54
53
|
# @return [void]
|
|
55
54
|
def stop_listener
|
|
56
55
|
@mutex.synchronize do
|
|
57
|
-
@listener
|
|
56
|
+
@listener&.stop
|
|
58
57
|
@listener = nil
|
|
59
58
|
end
|
|
60
59
|
end
|
|
@@ -110,7 +109,7 @@ module Sidekiq
|
|
|
110
109
|
# @return [void]
|
|
111
110
|
def ready(&handler)
|
|
112
111
|
@callbacks.on("ready", &handler)
|
|
113
|
-
yield if @listener
|
|
112
|
+
yield if @listener&.ready?
|
|
114
113
|
end
|
|
115
114
|
end
|
|
116
115
|
end
|
|
@@ -67,7 +67,7 @@ module Sidekiq
|
|
|
67
67
|
rescue Sidekiq::Shutdown
|
|
68
68
|
@terminated = true
|
|
69
69
|
@subscribed = false
|
|
70
|
-
rescue StandardError => e
|
|
70
|
+
rescue StandardError => e # rubocop:disable Style/RescueStandardError
|
|
71
71
|
@subscribed = false
|
|
72
72
|
handle_exception(e, { :context => "sidekiq:throttled" })
|
|
73
73
|
sleep 1
|
|
@@ -7,7 +7,7 @@ module Sidekiq
|
|
|
7
7
|
# @private
|
|
8
8
|
module QueueName
|
|
9
9
|
# RegExp used to stip out any redisr-namespace prefixes with `queue:`.
|
|
10
|
-
QUEUE_NAME_PREFIX_RE =
|
|
10
|
+
QUEUE_NAME_PREFIX_RE = /.*queue:/
|
|
11
11
|
private_constant :QUEUE_NAME_PREFIX_RE
|
|
12
12
|
|
|
13
13
|
class << self
|
|
@@ -24,10 +24,10 @@ module Sidekiq
|
|
|
24
24
|
# QueueName.normalize "foo:bar:queue:default"
|
|
25
25
|
# # => "default"
|
|
26
26
|
#
|
|
27
|
-
# @param [
|
|
27
|
+
# @param [#to_s]
|
|
28
28
|
# @return [String]
|
|
29
29
|
def normalize(queue)
|
|
30
|
-
queue.sub(QUEUE_NAME_PREFIX_RE, "")
|
|
30
|
+
queue.to_s.sub(QUEUE_NAME_PREFIX_RE, "")
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Prepends `queue:` prefix to given `queue` name.
|
|
@@ -35,7 +35,7 @@ module Sidekiq
|
|
|
35
35
|
# @note It does not normalizes queue before expanding it, thus
|
|
36
36
|
# double-call of this method will potentially do some harm.
|
|
37
37
|
#
|
|
38
|
-
# @param [
|
|
38
|
+
# @param [#to_s] queue Queue name
|
|
39
39
|
# @return [String]
|
|
40
40
|
def expand(queue)
|
|
41
41
|
"queue:#{queue}"
|
|
@@ -47,17 +47,17 @@ module Sidekiq
|
|
|
47
47
|
|
|
48
48
|
# @return [Boolean] whenever strategy has dynamic config
|
|
49
49
|
def dynamic?
|
|
50
|
-
return true if @concurrency
|
|
51
|
-
return true if @threshold
|
|
50
|
+
return true if @concurrency&.dynamic?
|
|
51
|
+
return true if @threshold&.dynamic?
|
|
52
52
|
|
|
53
53
|
false
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# @return [Boolean] whenever job is throttled or not.
|
|
57
57
|
def throttled?(jid, *job_args)
|
|
58
|
-
return true if @concurrency
|
|
58
|
+
return true if @concurrency&.throttled?(jid, *job_args)
|
|
59
59
|
|
|
60
|
-
if @threshold
|
|
60
|
+
if @threshold&.throttled?(*job_args)
|
|
61
61
|
finalize!(jid, *job_args)
|
|
62
62
|
return true
|
|
63
63
|
end
|
|
@@ -68,14 +68,14 @@ module Sidekiq
|
|
|
68
68
|
# Marks job as being processed.
|
|
69
69
|
# @return [void]
|
|
70
70
|
def finalize!(jid, *job_args)
|
|
71
|
-
@concurrency
|
|
71
|
+
@concurrency&.finalize!(jid, *job_args)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
# Resets count of jobs of all avaliable strategies
|
|
75
75
|
# @return [void]
|
|
76
76
|
def reset!
|
|
77
|
-
@concurrency
|
|
78
|
-
@threshold
|
|
77
|
+
@concurrency&.reset!
|
|
78
|
+
@threshold&.reset!
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -56,7 +56,7 @@ module Sidekiq
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
# rubocop:disable Metrics/
|
|
59
|
+
# rubocop:disable Metrics/AbcSize
|
|
60
60
|
def register_enhanced_queues_tab(app)
|
|
61
61
|
pauser = QueuesPauser.instance
|
|
62
62
|
|
|
@@ -75,7 +75,7 @@ module Sidekiq
|
|
|
75
75
|
redirect "#{root_path}enhanced-queues"
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
-
# rubocop:enable Metrics/
|
|
78
|
+
# rubocop:enable Metrics/AbcSize
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -14,9 +14,10 @@ module Sidekiq
|
|
|
14
14
|
|
|
15
15
|
# @param [Strategy::Concurrency, Strategy::Threshold] strategy
|
|
16
16
|
def initialize(strategy)
|
|
17
|
-
if strategy
|
|
17
|
+
if strategy&.dynamic?
|
|
18
18
|
raise ArgumentError, "Can't handle dynamic strategies"
|
|
19
19
|
end
|
|
20
|
+
|
|
20
21
|
@strategy = strategy
|
|
21
22
|
end
|
|
22
23
|
|
|
@@ -52,7 +53,9 @@ module Sidekiq
|
|
|
52
53
|
|
|
53
54
|
TIME_CONVERSION.each do |(dimension, unit, units)|
|
|
54
55
|
count = (int / dimension).to_i
|
|
55
|
-
|
|
56
|
+
|
|
57
|
+
next unless count.positive?
|
|
58
|
+
|
|
56
59
|
int -= count * dimension
|
|
57
60
|
arr << "#{count} #{1 == count ? unit : units}"
|
|
58
61
|
end
|
|
@@ -65,7 +68,7 @@ module Sidekiq
|
|
|
65
68
|
digits = int.to_s.split ""
|
|
66
69
|
str = digits.shift(digits.count % 3).join("")
|
|
67
70
|
|
|
68
|
-
str << " " << digits.shift(3).join("") while
|
|
71
|
+
str << " " << digits.shift(3).join("") while digits.count.positive?
|
|
69
72
|
|
|
70
73
|
str.strip
|
|
71
74
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
2
|
+
var elem = document.querySelector(".summary li.enqueued > a"), href;
|
|
3
|
+
|
|
4
|
+
if (!elem) {
|
|
5
|
+
console.warn("[Sidekiq::Threshold] cannot find summary bar link to fix");
|
|
6
|
+
} else {
|
|
7
|
+
href = elem.getAttribute("href").toString();
|
|
8
|
+
elem.setAttribute("href", href.replace(/\/queues$/, "/enhanced-queues"));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
@@ -4,22 +4,29 @@ module Sidekiq
|
|
|
4
4
|
module Throttled
|
|
5
5
|
module Web
|
|
6
6
|
module SummaryFix
|
|
7
|
-
|
|
7
|
+
JAVASCRIPT = [File.read(__FILE__.sub(/\.rb$/, ".js")).freeze].freeze
|
|
8
|
+
HEADERS = { "Content-Type" => "application/javascript" }.freeze
|
|
8
9
|
|
|
9
10
|
class << self
|
|
10
11
|
attr_accessor :enabled
|
|
11
12
|
|
|
12
13
|
def apply!(app)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
app.send(:prepend, SummaryFix)
|
|
14
|
+
Sidekiq::WebAction.send(:prepend, SummaryFix)
|
|
15
|
+
app.get("/throttled/summary_fix") do
|
|
16
|
+
[200, HEADERS.dup, JAVASCRIPT.dup]
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def display_custom_head
|
|
22
|
-
"#{super}#{
|
|
22
|
+
"#{super}#{summary_fix_script if SummaryFix.enabled}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def summary_fix_script
|
|
28
|
+
src = "#{root_path}throttled/summary_fix"
|
|
29
|
+
%(<script type="text/javascript" src="#{src}"></script>)
|
|
23
30
|
end
|
|
24
31
|
end
|
|
25
32
|
end
|
data/sidekiq-throttled.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path("
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
|
6
6
|
require "sidekiq/throttled/version"
|
|
@@ -24,8 +24,9 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
25
|
spec.require_paths = ["lib"]
|
|
26
26
|
|
|
27
|
-
spec.add_runtime_dependency "
|
|
27
|
+
spec.add_runtime_dependency "concurrent-ruby"
|
|
28
28
|
spec.add_runtime_dependency "redis-prescription"
|
|
29
|
+
spec.add_runtime_dependency "sidekiq"
|
|
29
30
|
|
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.10"
|
|
31
32
|
end
|
metadata
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sidekiq-throttled
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.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: 2018-
|
|
11
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: concurrent-ruby
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: sidekiq
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: bundler
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -62,8 +76,8 @@ files:
|
|
|
62
76
|
- ".coveralls.yml"
|
|
63
77
|
- ".gitignore"
|
|
64
78
|
- ".rspec"
|
|
65
|
-
- ".rubocop.todo.yml"
|
|
66
79
|
- ".rubocop.yml"
|
|
80
|
+
- ".rubocop_todo.yml"
|
|
67
81
|
- ".travis.yml"
|
|
68
82
|
- ".yardopts"
|
|
69
83
|
- Appraisals
|
|
@@ -73,11 +87,9 @@ files:
|
|
|
73
87
|
- LICENSE.md
|
|
74
88
|
- README.md
|
|
75
89
|
- Rakefile
|
|
76
|
-
- gemfiles/sidekiq_4.0.gemfile
|
|
77
|
-
- gemfiles/sidekiq_4.1.gemfile
|
|
78
|
-
- gemfiles/sidekiq_4.2.gemfile
|
|
79
90
|
- gemfiles/sidekiq_5.0.gemfile
|
|
80
91
|
- gemfiles/sidekiq_5.1.gemfile
|
|
92
|
+
- gemfiles/sidekiq_5.2.gemfile
|
|
81
93
|
- lib/sidekiq/throttled.rb
|
|
82
94
|
- lib/sidekiq/throttled/communicator.rb
|
|
83
95
|
- lib/sidekiq/throttled/communicator/callbacks.rb
|
|
@@ -102,7 +114,7 @@ files:
|
|
|
102
114
|
- lib/sidekiq/throttled/web.rb
|
|
103
115
|
- lib/sidekiq/throttled/web/queues.html.erb
|
|
104
116
|
- lib/sidekiq/throttled/web/stats.rb
|
|
105
|
-
- lib/sidekiq/throttled/web/summary_fix.
|
|
117
|
+
- lib/sidekiq/throttled/web/summary_fix.js
|
|
106
118
|
- lib/sidekiq/throttled/web/summary_fix.rb
|
|
107
119
|
- lib/sidekiq/throttled/web/throttled.html.erb
|
|
108
120
|
- lib/sidekiq/throttled/worker.rb
|
|
@@ -127,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
139
|
version: '0'
|
|
128
140
|
requirements: []
|
|
129
141
|
rubyforge_project:
|
|
130
|
-
rubygems_version: 2.7.
|
|
142
|
+
rubygems_version: 2.7.6
|
|
131
143
|
signing_key:
|
|
132
144
|
specification_version: 4
|
|
133
145
|
summary: Concurrency and threshold throttling for Sidekiq.
|
data/.rubocop.todo.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# need to review if it's possible to slim down methods down to 10 LOCs
|
|
2
|
-
# and if not, either disable this cop inline or bump up limits. in any
|
|
3
|
-
# case once we're clear on max allowed LOCs per method - it should be
|
|
4
|
-
# fixed in rubocop config (as rubocop constantly changing "best practices"
|
|
5
|
-
# according to moon's phase and wind's direction).
|
|
6
|
-
Metrics/MethodLength:
|
|
7
|
-
Exclude:
|
|
8
|
-
- lib/sidekiq/throttled/strategy.rb
|
|
9
|
-
- lib/sidekiq/throttled/queues_pauser.rb
|
|
10
|
-
- lib/sidekiq/throttled/communicator/callbacks.rb
|
|
11
|
-
- lib/sidekiq/throttled/communicator/listener.rb
|
|
12
|
-
|
|
13
|
-
# i have no strong feeling one way or the other, but probably using JSON for
|
|
14
|
-
# serializatino will be a bit more secure indeed.
|
|
15
|
-
Security/MarshalLoad:
|
|
16
|
-
Exclude:
|
|
17
|
-
- lib/sidekiq/throttled/communicator/listener.rb
|
|
18
|
-
|
|
19
|
-
# Enable this cop once we drop Ruby 2.2.x support.
|
|
20
|
-
Style/SafeNavigation:
|
|
21
|
-
Enabled: false
|
|
22
|
-
|
|
23
|
-
# Enable this cop once we drop Ruby 2.2.x support.
|
|
24
|
-
Style/NumericPredicate:
|
|
25
|
-
Enabled: false
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal"
|
|
6
|
-
gem "rake"
|
|
7
|
-
gem "redis-namespace", require: false
|
|
8
|
-
gem "rspec"
|
|
9
|
-
gem "rubocop", "~> 0.50.0", require: false
|
|
10
|
-
gem "sidekiq", "~> 4.1.0"
|
|
11
|
-
|
|
12
|
-
group :development do
|
|
13
|
-
gem "byebug"
|
|
14
|
-
gem "guard", require: false
|
|
15
|
-
gem "guard-rspec", require: false
|
|
16
|
-
gem "guard-rubocop", require: false
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
group :test do
|
|
20
|
-
gem "capybara"
|
|
21
|
-
gem "coveralls", require: false
|
|
22
|
-
gem "poltergeist"
|
|
23
|
-
gem "rack-test"
|
|
24
|
-
gem "simplecov", ">= 0.9"
|
|
25
|
-
gem "sinatra", "~> 1.4", ">= 1.4.6"
|
|
26
|
-
gem "timecop"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
gemspec path: "../"
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal"
|
|
6
|
-
gem "rake"
|
|
7
|
-
gem "redis-namespace", require: false
|
|
8
|
-
gem "rspec"
|
|
9
|
-
gem "rubocop", "~> 0.50.0", require: false
|
|
10
|
-
gem "sidekiq", "~> 4.2.0"
|
|
11
|
-
|
|
12
|
-
group :development do
|
|
13
|
-
gem "byebug"
|
|
14
|
-
gem "guard", require: false
|
|
15
|
-
gem "guard-rspec", require: false
|
|
16
|
-
gem "guard-rubocop", require: false
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
group :test do
|
|
20
|
-
gem "capybara"
|
|
21
|
-
gem "coveralls", require: false
|
|
22
|
-
gem "poltergeist"
|
|
23
|
-
gem "rack-test"
|
|
24
|
-
gem "simplecov", ">= 0.9"
|
|
25
|
-
gem "sinatra", "~> 1.4", ">= 1.4.6"
|
|
26
|
-
gem "timecop"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
gemspec path: "../"
|