sidekiq-throttled 0.11.0 → 0.12.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 +56 -0
- data/.rubocop.yml +35 -9
- data/.travis.yml +2 -1
- data/Appraisals +4 -0
- data/CHANGES.md +13 -0
- data/Gemfile +6 -5
- data/LICENSE.md +1 -1
- data/README.md +12 -8
- data/gemfiles/sidekiq_5.0.gemfile +6 -5
- data/gemfiles/sidekiq_5.1.gemfile +6 -5
- data/gemfiles/sidekiq_5.2.gemfile +6 -5
- data/gemfiles/sidekiq_6.0.gemfile +31 -0
- data/lib/sidekiq/throttled/communicator/callbacks.rb +1 -0
- data/lib/sidekiq/throttled/expirable_list.rb +1 -1
- data/lib/sidekiq/throttled/fetch.rb +11 -3
- data/lib/sidekiq/throttled/queue_name.rb +1 -1
- data/lib/sidekiq/throttled/registry.rb +2 -0
- data/lib/sidekiq/throttled/strategy.rb +1 -4
- data/lib/sidekiq/throttled/strategy/concurrency.rb +5 -5
- data/lib/sidekiq/throttled/strategy/threshold.rb +6 -5
- data/lib/sidekiq/throttled/version.rb +1 -1
- data/lib/sidekiq/throttled/web/stats.rb +2 -6
- data/lib/sidekiq/throttled/web/summary_fix.rb +2 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6112ba7b54891bb2026f3e01a299c61d063b4f7efae86ace8c189606ca9ecabf
|
4
|
+
data.tar.gz: 01e999a1093465e5ef702b4553215e1371b86c6dc024b2218b40988ad388ec91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba63bb6792f530028d937f629afc3e64be80fa03be250f986e1172af76b826ffbf5c23f43424f919ee83fd5d6d6b76f50589bfc656f642440b75c9c5f94b9aa8
|
7
|
+
data.tar.gz: b4df934846e581d6f06aee42f24142c556972a30b5b063906b86f01bc74f046b78520a30b5ca68770eac92849f60636bf55515eb7d928437cb3e1354e48815a3
|
@@ -0,0 +1,56 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
rspec:
|
11
|
+
name: "rspec (ruby:${{ matrix.ruby }} sidekiq:${{ matrix.sidekiq }})"
|
12
|
+
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby: [ "2.4", "2.5", "2.6", "2.7" ]
|
16
|
+
sidekiq: [ "5.0", "5.1", "5.2", "6.0" ]
|
17
|
+
exclude:
|
18
|
+
- { ruby: "2.4", sidekiq: "6.0" }
|
19
|
+
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
|
22
|
+
services:
|
23
|
+
redis:
|
24
|
+
image: redis
|
25
|
+
ports: ["6379:6379"]
|
26
|
+
options: "--entrypoint redis-server"
|
27
|
+
|
28
|
+
env:
|
29
|
+
GEMFILE: gemfiles/sidekiq_${{ matrix.sidekiq }}.gemfile
|
30
|
+
|
31
|
+
steps:
|
32
|
+
- uses: actions/checkout@v2
|
33
|
+
|
34
|
+
- uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
37
|
+
|
38
|
+
- name: bundle install
|
39
|
+
run: bundle install --without development --jobs 4 --retry 3
|
40
|
+
|
41
|
+
- run: bundle exec rspec
|
42
|
+
|
43
|
+
rubocop:
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v2
|
48
|
+
|
49
|
+
- uses: ruby/setup-ruby@v1
|
50
|
+
with:
|
51
|
+
ruby-version: "2.4"
|
52
|
+
|
53
|
+
- name: bundle install
|
54
|
+
run: bundle install --without development --jobs 4 --retry 3
|
55
|
+
|
56
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
@@ -14,24 +14,41 @@ AllCops:
|
|
14
14
|
|
15
15
|
## Layout ######################################################################
|
16
16
|
|
17
|
-
Layout/
|
18
|
-
EnforcedHashRocketStyle: table
|
19
|
-
|
20
|
-
Layout/AlignParameters:
|
17
|
+
Layout/ArgumentAlignment:
|
21
18
|
EnforcedStyle: with_fixed_indentation
|
22
19
|
|
23
|
-
Layout/
|
20
|
+
Layout/FirstArrayElementIndentation:
|
24
21
|
EnforcedStyle: consistent
|
25
22
|
|
26
|
-
Layout/
|
23
|
+
Layout/FirstHashElementIndentation:
|
27
24
|
EnforcedStyle: consistent
|
28
25
|
|
26
|
+
Layout/HashAlignment:
|
27
|
+
EnforcedHashRocketStyle: table
|
28
|
+
|
29
|
+
Layout/LineLength:
|
30
|
+
Max: 100
|
31
|
+
|
29
32
|
Layout/MultilineMethodCallIndentation:
|
30
33
|
EnforcedStyle: indented
|
31
34
|
|
35
|
+
Layout/ParameterAlignment:
|
36
|
+
EnforcedStyle: with_fixed_indentation
|
37
|
+
|
38
|
+
Layout/SpaceAroundMethodCallOperator:
|
39
|
+
Enabled: true
|
40
|
+
|
32
41
|
Layout/SpaceInLambdaLiteral:
|
33
42
|
EnforcedStyle: require_space
|
34
43
|
|
44
|
+
## Lint ########################################################################
|
45
|
+
|
46
|
+
Lint/RaiseException:
|
47
|
+
Enabled: true
|
48
|
+
|
49
|
+
Lint/StructNewOverride:
|
50
|
+
Enabled: true
|
51
|
+
|
35
52
|
## Metrics #####################################################################
|
36
53
|
|
37
54
|
Metrics/BlockLength:
|
@@ -41,15 +58,24 @@ Metrics/BlockLength:
|
|
41
58
|
|
42
59
|
## Styles ######################################################################
|
43
60
|
|
44
|
-
Style/BracesAroundHashParameters:
|
45
|
-
Enabled: false
|
46
|
-
|
47
61
|
Style/Documentation:
|
48
62
|
Enabled: false
|
49
63
|
|
64
|
+
Style/ExponentialNotation:
|
65
|
+
Enabled: true
|
66
|
+
|
67
|
+
Style/HashEachMethods:
|
68
|
+
Enabled: true
|
69
|
+
|
50
70
|
Style/HashSyntax:
|
51
71
|
EnforcedStyle: hash_rockets
|
52
72
|
|
73
|
+
Style/HashTransformKeys:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
Style/HashTransformValues:
|
77
|
+
Enabled: true
|
78
|
+
|
53
79
|
# Follow your heart where it makes sense to use lambda or lambda literal.
|
54
80
|
# Enforcing it makes some pieces of code look REALLY terrible, e.g. in
|
55
81
|
# case of empty (noop) lambdas: `lambda { |_| }`.
|
data/.travis.yml
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
2
|
|
4
3
|
services:
|
5
4
|
- redis-server
|
@@ -23,6 +22,7 @@ rvm:
|
|
23
22
|
- 2.4
|
24
23
|
- 2.5
|
25
24
|
- 2.6
|
25
|
+
- 2.7
|
26
26
|
|
27
27
|
matrix:
|
28
28
|
fast_finish: true
|
@@ -36,3 +36,4 @@ gemfile:
|
|
36
36
|
- gemfiles/sidekiq_5.0.gemfile
|
37
37
|
- gemfiles/sidekiq_5.1.gemfile
|
38
38
|
- gemfiles/sidekiq_5.2.gemfile
|
39
|
+
- gemfiles/sidekiq_6.0.gemfile
|
data/Appraisals
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.12.0 (2020-06-22)
|
2
|
+
|
3
|
+
* [#80](https://github.com/sensortower/sidekiq-throttled/pull/80)
|
4
|
+
Allow override cooldown timeout of queues with throttled jobs.
|
5
|
+
([@vaot])
|
6
|
+
|
7
|
+
* [#76](https://github.com/sensortower/sidekiq-throttled/pull/76)
|
8
|
+
Fix warnings on Ruby 2.7
|
9
|
+
([@lenon])
|
10
|
+
|
11
|
+
|
1
12
|
## 0.11.0 (2019-08-24)
|
2
13
|
|
3
14
|
* [#59](https://github.com/sensortower/sidekiq-throttled/pull/59)
|
@@ -201,3 +212,5 @@
|
|
201
212
|
[@mstruve]: https://github.com/mstruve
|
202
213
|
[@ziaulrehman40]: https://github.com/ziaulrehman40
|
203
214
|
[@ogins57]: https://github.com/ogins57
|
215
|
+
[@lenon]: https://github.com/lenon
|
216
|
+
[@vaot]: https://github.com/vaot
|
data/Gemfile
CHANGED
@@ -5,8 +5,9 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake"
|
7
7
|
gem "rspec"
|
8
|
-
gem "rubocop",
|
9
|
-
gem "rubocop-
|
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
|
10
11
|
gem "sidekiq"
|
11
12
|
|
12
13
|
group :development do
|
@@ -17,13 +18,13 @@ group :development do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
group :test do
|
21
|
+
gem "apparition"
|
20
22
|
gem "capybara"
|
21
23
|
gem "coveralls", :require => false
|
22
|
-
gem "poltergeist"
|
23
24
|
gem "puma"
|
24
25
|
gem "rack-test"
|
25
|
-
gem "simplecov"
|
26
|
-
gem "sinatra"
|
26
|
+
gem "simplecov"
|
27
|
+
gem "sinatra"
|
27
28
|
gem "timecop"
|
28
29
|
end
|
29
30
|
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015-
|
3
|
+
Copyright (c) 2015-2020 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
@@ -1,14 +1,14 @@
|
|
1
1
|
# Sidekiq::Throttled
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![
|
5
|
-
[![Code
|
6
|
-
[![Coverage
|
7
|
-
[![API Docs](http://inch-ci.org/github/sensortower/sidekiq-throttled.svg?branch=master)](http://inch-ci.org/github/sensortower/sidekiq-throttled)
|
3
|
+
[![Latest Version](https://badge.fury.io/rb/sidekiq-throttled.svg)](http://rubygems.org/gems/sidekiq-throttled)
|
4
|
+
[![CI Status](https://github.com/sensortower/sidekiq-throttled/workflows/CI/badge.svg?branch=master)](https://github.com/sensortower/sidekiq-throttled/actions?query=workflow%3ACI+branch%3Amaster)
|
5
|
+
[![Code Quality](https://codeclimate.com/github/sensortower/sidekiq-throttled.svg?branch=master)](https://codeclimate.com/github/sensortower/sidekiq-throttled)
|
6
|
+
[![Code Coverage](https://coveralls.io/repos/github/sensortower/sidekiq-throttled/badge.svg?branch=master)](https://coveralls.io/github/sensortower/sidekiq-throttled?branch=master)
|
7
|
+
[![API Docs Quality](http://inch-ci.org/github/sensortower/sidekiq-throttled.svg?branch=master)](http://inch-ci.org/github/sensortower/sidekiq-throttled)
|
8
|
+
[![API Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/gems/sidekiq-throttled)
|
8
9
|
|
9
10
|
Concurrency and threshold throttling for [Sidekiq][sidekiq].
|
10
11
|
|
11
|
-
|
12
12
|
## Installation
|
13
13
|
|
14
14
|
Add this line to your application's Gemfile:
|
@@ -36,6 +36,9 @@ require "sidekiq/throttled"
|
|
36
36
|
Sidekiq::Throttled.setup!
|
37
37
|
```
|
38
38
|
|
39
|
+
Load order can be an issue if you are using other Sidekiq plugins and/or middleware.
|
40
|
+
To prevent any problems, add the `.setup!` call to the bottom of your init file.
|
41
|
+
|
39
42
|
Once you've done that you can include `Sidekiq::Throttled::Worker` to your
|
40
43
|
job classes and configure throttling:
|
41
44
|
|
@@ -88,7 +91,7 @@ end
|
|
88
91
|
```
|
89
92
|
|
90
93
|
Observer will receive `strategy, *args` arguments, where `strategy` is a Symbol
|
91
|
-
`:concurrency` or `:threshold`, and `*args` are the
|
94
|
+
`:concurrency` or `:threshold`, and `*args` are the arguments that were passed
|
92
95
|
to the job.
|
93
96
|
|
94
97
|
|
@@ -231,6 +234,7 @@ This library aims to support work with following [Sidekiq][sidekiq] versions:
|
|
231
234
|
* Sidekiq 5.0.x
|
232
235
|
* Sidekiq 5.1.x
|
233
236
|
* Sidekiq 5.2.x
|
237
|
+
* Sidekiq 6.0.x
|
234
238
|
|
235
239
|
|
236
240
|
## Contributing
|
@@ -258,7 +262,7 @@ Don't forget to run `appraisal update` after any changes to `Gemfile`.
|
|
258
262
|
|
259
263
|
## Copyright
|
260
264
|
|
261
|
-
Copyright (c) 2015-
|
265
|
+
Copyright (c) 2015-2020 SensorTower Inc.
|
262
266
|
See LICENSE.md for further details.
|
263
267
|
|
264
268
|
|
@@ -5,8 +5,9 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake"
|
7
7
|
gem "rspec"
|
8
|
-
gem "rubocop", "~> 0.
|
9
|
-
gem "rubocop-
|
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
|
10
11
|
gem "sidekiq", "~> 5.0.0"
|
11
12
|
|
12
13
|
group :development do
|
@@ -17,13 +18,13 @@ group :development do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
group :test do
|
21
|
+
gem "apparition"
|
20
22
|
gem "capybara"
|
21
23
|
gem "coveralls", require: false
|
22
|
-
gem "poltergeist"
|
23
24
|
gem "puma"
|
24
25
|
gem "rack-test"
|
25
|
-
gem "simplecov"
|
26
|
-
gem "sinatra"
|
26
|
+
gem "simplecov"
|
27
|
+
gem "sinatra"
|
27
28
|
gem "timecop"
|
28
29
|
end
|
29
30
|
|
@@ -5,8 +5,9 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake"
|
7
7
|
gem "rspec"
|
8
|
-
gem "rubocop", "~> 0.
|
9
|
-
gem "rubocop-
|
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
|
10
11
|
gem "sidekiq", "~> 5.1.0"
|
11
12
|
|
12
13
|
group :development do
|
@@ -17,13 +18,13 @@ group :development do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
group :test do
|
21
|
+
gem "apparition"
|
20
22
|
gem "capybara"
|
21
23
|
gem "coveralls", require: false
|
22
|
-
gem "poltergeist"
|
23
24
|
gem "puma"
|
24
25
|
gem "rack-test"
|
25
|
-
gem "simplecov"
|
26
|
-
gem "sinatra"
|
26
|
+
gem "simplecov"
|
27
|
+
gem "sinatra"
|
27
28
|
gem "timecop"
|
28
29
|
end
|
29
30
|
|
@@ -5,8 +5,9 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake"
|
7
7
|
gem "rspec"
|
8
|
-
gem "rubocop", "~> 0.
|
9
|
-
gem "rubocop-
|
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
|
10
11
|
gem "sidekiq", "~> 5.2.0"
|
11
12
|
|
12
13
|
group :development do
|
@@ -17,13 +18,13 @@ group :development do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
group :test do
|
21
|
+
gem "apparition"
|
20
22
|
gem "capybara"
|
21
23
|
gem "coveralls", require: false
|
22
|
-
gem "poltergeist"
|
23
24
|
gem "puma"
|
24
25
|
gem "rack-test"
|
25
|
-
gem "simplecov"
|
26
|
-
gem "sinatra"
|
26
|
+
gem "simplecov"
|
27
|
+
gem "sinatra"
|
27
28
|
gem "timecop"
|
28
29
|
end
|
29
30
|
|
@@ -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.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: "../"
|
@@ -11,7 +11,7 @@ module Sidekiq
|
|
11
11
|
#
|
12
12
|
# ## Implementation
|
13
13
|
#
|
14
|
-
# Internally list holds an array of arrays. Thus
|
14
|
+
# Internally list holds an array of arrays. Thus each element is a tuple of
|
15
15
|
# monotonic timestamp (when element was added) and element itself:
|
16
16
|
#
|
17
17
|
# [
|
@@ -17,11 +17,19 @@ module Sidekiq
|
|
17
17
|
TIMEOUT = 2
|
18
18
|
|
19
19
|
# Initializes fetcher instance.
|
20
|
+
# @param options [Hash]
|
21
|
+
# @option options [Integer] :throttled_queue_cooldown (TIMEOUT)
|
22
|
+
# Min delay in seconds before queue will be polled again after
|
23
|
+
# throttled job.
|
24
|
+
# @option options [Boolean] :strict (false)
|
25
|
+
# @option options [Array<#to_s>] :queue
|
20
26
|
def initialize(options)
|
21
|
-
@paused = ExpirableList.new(TIMEOUT)
|
27
|
+
@paused = ExpirableList.new(options.fetch(:throttled_queue_cooldown, TIMEOUT))
|
22
28
|
|
23
|
-
@strict = options
|
24
|
-
@queues = options
|
29
|
+
@strict = options.fetch(:strict, false)
|
30
|
+
@queues = options.fetch(:queues).map { |q| QueueName.expand q }
|
31
|
+
|
32
|
+
raise ArgumentError, "empty :queues" if @queues.empty?
|
25
33
|
|
26
34
|
@queues.uniq! if @strict
|
27
35
|
end
|
@@ -74,6 +74,7 @@ module Sidekiq
|
|
74
74
|
# @return [Registry]
|
75
75
|
def each
|
76
76
|
return to_enum(__method__) unless block_given?
|
77
|
+
|
77
78
|
@strategies.each { |*args| yield(*args) }
|
78
79
|
self
|
79
80
|
end
|
@@ -88,6 +89,7 @@ module Sidekiq
|
|
88
89
|
# @return [Registry]
|
89
90
|
def each_with_static_keys
|
90
91
|
return to_enum(__method__) unless block_given?
|
92
|
+
|
91
93
|
@strategies.each do |name, strategy|
|
92
94
|
yield(name, strategy) unless strategy.dynamic?
|
93
95
|
end
|
@@ -86,10 +86,7 @@ module Sidekiq
|
|
86
86
|
def make_strategy(strategy, name, key_suffix, options)
|
87
87
|
return unless options
|
88
88
|
|
89
|
-
strategy.new("throttled:#{name}",
|
90
|
-
:key_suffix => key_suffix,
|
91
|
-
**options
|
92
|
-
})
|
89
|
+
strategy.new("throttled:#{name}", :key_suffix => key_suffix, **options)
|
93
90
|
end
|
94
91
|
end
|
95
92
|
end
|
@@ -46,12 +46,12 @@ module Sidekiq
|
|
46
46
|
return false unless job_limit
|
47
47
|
return true if job_limit <= 0
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
:argv => [jid.to_s, job_limit, @ttl, Time.now.to_f]
|
52
|
-
}
|
49
|
+
keys = [key(job_args)]
|
50
|
+
argv = [jid.to_s, job_limit, @ttl, Time.now.to_f]
|
53
51
|
|
54
|
-
Sidekiq.redis
|
52
|
+
Sidekiq.redis do |redis|
|
53
|
+
1 == SCRIPT.eval(redis, :keys => keys, :argv => argv)
|
54
|
+
end
|
55
55
|
end
|
56
56
|
|
57
57
|
# @return [Integer] Current count of jobs
|
@@ -48,6 +48,7 @@ module Sidekiq
|
|
48
48
|
# @return [Float] Period in seconds
|
49
49
|
def period(job_args = nil)
|
50
50
|
return @period.to_f unless @period.respond_to? :call
|
51
|
+
|
51
52
|
@period.call(*job_args).to_f
|
52
53
|
end
|
53
54
|
|
@@ -62,12 +63,12 @@ module Sidekiq
|
|
62
63
|
return false unless job_limit
|
63
64
|
return true if job_limit <= 0
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
:argv => [job_limit, period(job_args), Time.now.to_f]
|
68
|
-
}
|
66
|
+
keys = [key(job_args)]
|
67
|
+
argv = [job_limit, period(job_args), Time.now.to_f]
|
69
68
|
|
70
|
-
Sidekiq.redis
|
69
|
+
Sidekiq.redis do |redis|
|
70
|
+
1 == SCRIPT.eval(redis, :keys => keys, :argv => argv)
|
71
|
+
end
|
71
72
|
end
|
72
73
|
|
73
74
|
# @return [Integer] Current count of jobs
|
@@ -14,9 +14,7 @@ module Sidekiq
|
|
14
14
|
|
15
15
|
# @param [Strategy::Concurrency, Strategy::Threshold] strategy
|
16
16
|
def initialize(strategy)
|
17
|
-
if strategy&.dynamic?
|
18
|
-
raise ArgumentError, "Can't handle dynamic strategies"
|
19
|
-
end
|
17
|
+
raise ArgumentError, "Can't handle dynamic strategies" if strategy&.dynamic?
|
20
18
|
|
21
19
|
@strategy = strategy
|
22
20
|
end
|
@@ -27,9 +25,7 @@ module Sidekiq
|
|
27
25
|
|
28
26
|
html = humanize_integer(@strategy.limit) << " jobs"
|
29
27
|
|
30
|
-
if @strategy.respond_to?
|
31
|
-
html << " per " << humanize_duration(@strategy.period)
|
32
|
-
end
|
28
|
+
html << " per " << humanize_duration(@strategy.period) if @strategy.respond_to?(:period)
|
33
29
|
|
34
30
|
html << "<br />" << colorize_count(@strategy.count, @strategy.limit)
|
35
31
|
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.12.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:
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".coveralls.yml"
|
77
|
+
- ".github/workflows/ci.yml"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".rubocop.yml"
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- gemfiles/sidekiq_5.0.gemfile
|
91
92
|
- gemfiles/sidekiq_5.1.gemfile
|
92
93
|
- gemfiles/sidekiq_5.2.gemfile
|
94
|
+
- gemfiles/sidekiq_6.0.gemfile
|
93
95
|
- lib/sidekiq/throttled.rb
|
94
96
|
- lib/sidekiq/throttled/communicator.rb
|
95
97
|
- lib/sidekiq/throttled/communicator/callbacks.rb
|
@@ -140,7 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
142
|
- !ruby/object:Gem::Version
|
141
143
|
version: '0'
|
142
144
|
requirements: []
|
143
|
-
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.7.6.2
|
144
147
|
signing_key:
|
145
148
|
specification_version: 4
|
146
149
|
summary: Concurrency and threshold throttling for Sidekiq.
|