sidekiq-throttler 0.4.1 → 0.5.1

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: 19e1d69fd9be458ce6356483854f19513b01e5e7
4
- data.tar.gz: 1c0582120520cfa48ce066cf410f7d48c492a394
3
+ metadata.gz: 8510cc5fa63ec9ee28c5e6cac2f2adda038f754f
4
+ data.tar.gz: 9c31136eda0f75f97c71c70e9455066748c8f6d4
5
5
  SHA512:
6
- metadata.gz: 35a019db24bfd3833fa22edfed15b00b144b9a73966de3b9c075f794b832ba7e4cf4791f633f8432cc35ad21e9ace738d94635268c5b0109b6c866dc1d68832f
7
- data.tar.gz: 1d74ed077c71d2ff8630d0286958a2869ca3bb4a83e6f3b5fa74f967cfbf7312ae05150176b14f34883fb827ea7bad5438527f138afb8ee8a6530e3a0542406a
6
+ metadata.gz: 7fd700bebbd83427aa0cba1a33adb42dde2e33ecd012150e25e7e427e0fcc956e240f434a6e5aac0fd95de4d667e478a0402183a34d5b8eabdf12860654662a7
7
+ data.tar.gz: 91259a25d5a10ad998eb51bdfbe866e878a43f61d09b08ef0790625fdc68644b67ad6a4d6d8625645171af995e0349e520985f12242fad846b4a62e37bbb8ed7
@@ -2,17 +2,18 @@ language: ruby
2
2
  services:
3
3
  - redis-server
4
4
  rvm:
5
- - 2.1.1
6
- - 2.1.0
5
+ - 2.3.0
6
+ - 2.2
7
+ - 2.1
7
8
  - 2.0.0
8
- - 1.9.3
9
- branches:
10
- only:
11
- - master
12
9
  notifications:
13
10
  email:
14
11
  recipients:
15
12
  - gabe@ga.be
16
13
  gemfile:
14
+ - gemfiles/sidekiq_head.gemfile
15
+ - gemfiles/sidekiq_4.gemfile
16
+ - gemfiles/sidekiq_3.gemfile
17
17
  - gemfiles/sidekiq_2.gemfile
18
- - gemfiles/sidekiq_master.gemfile
18
+ before_install:
19
+ - gem update bundler
data/Appraisals CHANGED
@@ -1,7 +1,15 @@
1
- appraise 'sidekiq-2' do
2
- gem 'sidekiq', '2.17.7'
1
+ appraise 'sidekiq-head' do
2
+ gem 'sidekiq', github: 'mperham/sidekiq'
3
3
  end
4
4
 
5
- appraise 'sidekiq-master' do
6
- gem 'sidekiq', github: 'mperham/sidekiq'
5
+ appraise 'sidekiq-4' do
6
+ gem 'sidekiq', '~> 4.0'
7
+ end
8
+
9
+ appraise 'sidekiq-3' do
10
+ gem 'sidekiq', '~> 3.0'
11
+ end
12
+
13
+ appraise 'sidekiq-2' do
14
+ gem 'sidekiq', '~> 2.0'
7
15
  end
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in sidekiq-throttler.gemspec
4
4
  gemspec
5
5
 
6
- gem 'appraisal', '~> 1.0.0'
6
+ gem 'appraisal', '~> 2.1.0'
data/README.md CHANGED
@@ -9,8 +9,7 @@ limit job execution on a per-worker basis.
9
9
 
10
10
  ## Compatibility
11
11
 
12
- Sidekiq::Throttler is actively tested against MRI versions 2.1.1, 2.1.0, 2.0.0,
13
- and 1.9.3.
12
+ Sidekiq::Throttler supports Sidekiq versions 2 and 3 and is actively tested against Ruby versions 2.0.0, 2.1, and 2.2.
14
13
 
15
14
  ## Installation
16
15
 
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'appraisal' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("appraisal", "appraisal")
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'guard' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("guard", "guard")
data/bin/pry ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'pry' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("pry", "pry")
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'yard' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("yard", "yard")
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 1.0.0"
6
- gem "sidekiq", "2.17.7"
5
+ gem "appraisal", "~> 2.1.0"
6
+ gem "sidekiq", "~> 2.0"
7
7
 
8
8
  gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 2.1.0"
6
+ gem "sidekiq", "~> 3.0"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 2.1.0"
6
+ gem "sidekiq", "~> 4.0"
7
+
8
+ gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 1.0.0"
5
+ gem "appraisal", "~> 2.1.0"
6
6
  gem "sidekiq", :github => "mperham/sidekiq"
7
7
 
8
8
  gemspec :path => "../"
@@ -1,3 +1,5 @@
1
+ require 'thread'
2
+
1
3
  module Sidekiq
2
4
  class Throttler
3
5
  ##
@@ -8,6 +10,8 @@ module Sidekiq
8
10
  # and 30 seconds"
9
11
  class RateLimit
10
12
 
13
+ LOCK = Mutex.new
14
+
11
15
  ##
12
16
  # @return [Sidekiq::Worker]
13
17
  # The worker to rate limit.
@@ -174,7 +178,7 @@ module Sidekiq
174
178
  # @return [Integer]
175
179
  # The current number of jobs executed.
176
180
  def self.count(limiter)
177
- Thread.exclusive do
181
+ LOCK.synchronize do
178
182
  prune(limiter)
179
183
  limiter.executions.count(limiter.key)
180
184
  end
@@ -188,7 +192,7 @@ module Sidekiq
188
192
  # @return [Integer]
189
193
  # The current number of jobs executed.
190
194
  def self.increment(limiter)
191
- Thread.exclusive do
195
+ LOCK.synchronize do
192
196
  limiter.executions.append(limiter.key, Time.now)
193
197
  end
194
198
  count(limiter)
@@ -13,7 +13,7 @@ module Sidekiq
13
13
  ##
14
14
  # Number of executions for +key+.
15
15
  #
16
- # @param [String]
16
+ # @param [String] key
17
17
  # Key to fetch count for
18
18
  #
19
19
  # @return [Fixnum]
@@ -40,7 +40,7 @@ module Sidekiq
40
40
  # @param [String] key
41
41
  # The key to append to
42
42
  #
43
- # @param [Time]
43
+ # @param [Time] time
44
44
  # The time to insert
45
45
  def append(key, time)
46
46
  @hash[key] << time
@@ -12,7 +12,7 @@ module Sidekiq
12
12
  ##
13
13
  # Number of executions for +key+.
14
14
  #
15
- # @param [String]
15
+ # @param [String] key
16
16
  # Key to fetch count for
17
17
  #
18
18
  # @return [Fixnum]
@@ -60,7 +60,7 @@ module Sidekiq
60
60
  # @param [String] key
61
61
  # The key to append to
62
62
  #
63
- # @param [Time]
63
+ # @param [Time] time
64
64
  # The time to insert
65
65
  def append(key, time)
66
66
  Sidekiq.redis do |conn|
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  class Throttler
3
- VERSION = '0.4.1'
3
+ VERSION = '0.5.1'.freeze
4
4
  end
5
5
  end
@@ -14,12 +14,11 @@ Gem::Specification.new do |gem|
14
14
  gem.license = 'MIT'
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
18
  gem.require_paths = %w(lib)
20
19
 
21
20
  gem.add_dependency 'activesupport'
22
- gem.add_dependency 'sidekiq', '>= 2.5', '< 4.0'
21
+ gem.add_dependency 'sidekiq', '>= 2.5', '< 5.0'
23
22
 
24
23
  gem.add_development_dependency 'growl'
25
24
  gem.add_development_dependency 'guard'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-throttler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabe Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '2.5'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '4.0'
36
+ version: '5.0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.5'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '4.0'
46
+ version: '5.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: growl
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -273,8 +273,16 @@ files:
273
273
  - LICENSE.txt
274
274
  - README.md
275
275
  - Rakefile
276
+ - bin/appraisal
277
+ - bin/guard
278
+ - bin/pry
279
+ - bin/rake
280
+ - bin/rspec
281
+ - bin/yard
276
282
  - gemfiles/sidekiq_2.gemfile
277
- - gemfiles/sidekiq_master.gemfile
283
+ - gemfiles/sidekiq_3.gemfile
284
+ - gemfiles/sidekiq_4.gemfile
285
+ - gemfiles/sidekiq_head.gemfile
278
286
  - lib/sidekiq-throttler.rb
279
287
  - lib/sidekiq/throttler.rb
280
288
  - lib/sidekiq/throttler/rate_limit.rb
@@ -313,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
321
  version: '0'
314
322
  requirements: []
315
323
  rubyforge_project:
316
- rubygems_version: 2.2.2
324
+ rubygems_version: 2.5.1
317
325
  signing_key:
318
326
  specification_version: 4
319
327
  summary: Sidekiq::Throttler is a middleware for Sidekiq that adds the ability to rate