sidekiq-throttled 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f24a091044117cd299dc478eca0cdf2592b7e05
4
- data.tar.gz: 18cd12c9b4a9a8e4ce273f959a4deae29c7d2c14
3
+ metadata.gz: 533d15834069284a6d4a781438724390ae8c185e
4
+ data.tar.gz: e7ef6171c7d1d50f4e73ca2d856ada94a861cd93
5
5
  SHA512:
6
- metadata.gz: d02ac4f96d6aaf4cae1d0b2a5958efbef48d86410c18b933f9da3fb492c5e6487a7dd6bcf612e1858e0bd0c355827f6b6071341ea2b42ad73b9f59d805cfe8d6
7
- data.tar.gz: e9c0d68e0fc016cdbd5369f8d342339fde7c0e67f40cd1a1446025839ccbf7f9c26f9eabed5fafa8521387d93ae3bb61483cfd2f5cae6722488833fc90148939
6
+ metadata.gz: eb0e8c60fa207fc0c79b051640ee6d0c4312e91f5b5fe327a48a383ff8c21cc706c57de346c71aa5c750e4b19339da3d700858c26574717a130393d20957ae69
7
+ data.tar.gz: 0d4c82ed8ff3e7af23e4adfeec283c40d4fe200de4342fad333b174e8b9f64ae6fb22641c916fea0aed9bc0a4dbe0611936a350ad691c2b360ded39a3769b6c7
data/.travis.yml CHANGED
@@ -17,6 +17,9 @@ gemfile:
17
17
  - gemfiles/sidekiq_4.0.gemfile
18
18
  - gemfiles/sidekiq_4.1.gemfile
19
19
  - gemfiles/sidekiq_latest.gemfile
20
+ env:
21
+ - WITH_REDIS_NAMESPACE=0
22
+ - WITH_REDIS_NAMESPACE=1
20
23
  before_install:
21
24
  - gem install bundler -v 1.10.6
22
25
  services:
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.6.6 (2016-10-16)
2
+
3
+ * [#24](https://github.com/sensortower/sidekiq-throttled/pull/24)
4
+ Fix dynamic `:key_suffix` issue.
5
+ ([@iporsut])
6
+
7
+
1
8
  ## 0.6.5 (2016-09-04)
2
9
 
3
10
  * Fix concurrency throttling when redis-namespace is used.
@@ -93,3 +100,4 @@
93
100
  [@fhwang]: https://github.com/fhwang
94
101
  [@palanglung]: https://github.com/palanglung
95
102
  [@azach]: https://github.com/azach
103
+ [@iporsut]: https://github.com/iporsut
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem "appraisal"
6
6
  gem "rake"
7
7
  gem "rspec"
8
8
  gem "rubocop", "~> 0.42.0", :require => false
9
+ gem "redis-namespace", :require => false
9
10
 
10
11
  group :test do
11
12
  gem "coveralls", :require => false
@@ -6,10 +6,11 @@ gem "appraisal"
6
6
  gem "rake"
7
7
  gem "rspec"
8
8
  gem "rubocop", "~> 0.42.0", :require => false
9
+ gem "redis-namespace", :require => false
9
10
  gem "sidekiq", "~> 4.0.0"
10
11
 
11
12
  group :test do
12
- gem "coveralls"
13
+ gem "coveralls", :require => false
13
14
  gem "rack-test"
14
15
  gem "simplecov", ">= 0.9"
15
16
  gem "sinatra", "~> 1.4", ">= 1.4.6"
@@ -6,10 +6,11 @@ gem "appraisal"
6
6
  gem "rake"
7
7
  gem "rspec"
8
8
  gem "rubocop", "~> 0.42.0", :require => false
9
+ gem "redis-namespace", :require => false
9
10
  gem "sidekiq", "~> 4.1.0"
10
11
 
11
12
  group :test do
12
- gem "coveralls"
13
+ gem "coveralls", :require => false
13
14
  gem "rack-test"
14
15
  gem "simplecov", ">= 0.9"
15
16
  gem "sinatra", "~> 1.4", ">= 1.4.6"
@@ -6,10 +6,11 @@ gem "appraisal"
6
6
  gem "rake"
7
7
  gem "rspec"
8
8
  gem "rubocop", "~> 0.42.0", :require => false
9
+ gem "redis-namespace", :require => false
9
10
  gem "sidekiq"
10
11
 
11
12
  group :test do
12
- gem "coveralls"
13
+ gem "coveralls", :require => false
13
14
  gem "rack-test"
14
15
  gem "simplecov", ">= 0.9"
15
16
  gem "sinatra", "~> 1.4", ">= 1.4.6"
@@ -20,23 +20,23 @@ module Sidekiq
20
20
 
21
21
  # @param [#to_s] name
22
22
  # @param [Hash] concurrency Concurrency options.
23
- # See {Strategy::Concurrency#initialize} for details.
23
+ # See keyword args of {Strategy::Concurrency#initialize} for details.
24
24
  # @param [Hash] threshold Threshold options.
25
- # See {Strategy::Threshold#initialize} for details.
26
- # @param [Hash] key_suffix Proc for dynamic keys.
25
+ # See keyword args of {Strategy::Threshold#initialize} for details.
26
+ # @param [#call] key_suffix Dynamic key suffix generator.
27
27
  def initialize(name, concurrency: nil, threshold: nil, key_suffix: nil)
28
28
  key = "throttled:#{name}"
29
29
 
30
30
  @concurrency =
31
31
  if concurrency
32
- concurrency[:key_suffix] = key_suffix
33
- Concurrency.new(key, concurrency)
32
+ concurrency[:key_suffix] ||= key_suffix
33
+ Concurrency.new(key, **concurrency)
34
34
  end
35
35
 
36
36
  @threshold =
37
37
  if threshold
38
- threshold[:key_suffix] = key_suffix
39
- Threshold.new(key, threshold)
38
+ threshold[:key_suffix] ||= key_suffix
39
+ Threshold.new(key, **threshold)
40
40
  end
41
41
 
42
42
  return if @concurrency || @threshold
@@ -18,17 +18,15 @@ module Sidekiq
18
18
  private_constant :SCRIPT
19
19
 
20
20
  # @param [#to_s] strategy_key
21
- # @param [Hash] opts
22
- # @option opts [#to_i] :limit Amount of allowed concurrent jobs
23
- # processors running for given key
24
- # @option opts [#to_i] :ttl (15 minutes) Concurrency lock TTL
25
- # in seconds
26
- # @option opts :key_suffix Proc for dynamic key suffix.
27
- def initialize(strategy_key, opts)
21
+ # @param [#to_i, #call] limit Amount of allowed concurrent jobs
22
+ # per processors running for given key.
23
+ # @param [#to_i] ttl Concurrency lock TTL in seconds.
24
+ # @param [Proc] key_suffix Dynamic key suffix generator.
25
+ def initialize(strategy_key, limit:, ttl: 900, key_suffix: nil)
28
26
  @base_key = "#{strategy_key}:concurrency".freeze
29
- @limit = opts.fetch(:limit)
30
- @ttl = opts.fetch(:ttl, 900).to_i
31
- @key_suffix = opts[:key_suffix]
27
+ @limit = limit
28
+ @ttl = ttl.to_i
29
+ @key_suffix = key_suffix
32
30
  end
33
31
 
34
32
  # @return [Integer] Amount of allowed concurrent job processors
@@ -30,14 +30,15 @@ module Sidekiq
30
30
  private_constant :SCRIPT
31
31
 
32
32
  # @param [#to_s] strategy_key
33
- # @param [Hash] opts
34
- # @option opts [#to_i] :limit Amount of jobs allowed per period
35
- # @option opts [#to_f] :period Period in seconds
36
- def initialize(strategy_key, opts)
33
+ # @param [#to_i, #call] limit Amount of allowed concurrent jobs
34
+ # per period running for given key.
35
+ # @param [#to_f, #call] :period Period in seconds.
36
+ # @param [Proc] key_suffix Dynamic key suffix generator.
37
+ def initialize(strategy_key, limit:, period:, key_suffix: nil)
37
38
  @base_key = "#{strategy_key}:threshold".freeze
38
- @limit = opts.fetch(:limit)
39
- @period = opts.fetch(:period)
40
- @key_suffix = opts[:key_suffix]
39
+ @limit = limit
40
+ @period = period
41
+ @key_suffix = key_suffix
41
42
  end
42
43
 
43
44
  # @return [Integer] Amount of jobs allowed per period
@@ -3,6 +3,6 @@
3
3
  module Sidekiq
4
4
  module Throttled
5
5
  # Gem version
6
- VERSION = "0.6.5".freeze
6
+ VERSION = "0.6.6".freeze
7
7
  end
8
8
  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.6.5
4
+ version: 0.6.6
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: 2016-09-04 00:00:00.000000000 Z
11
+ date: 2016-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq