sidekiq-throttled 0.2.0 → 0.3.0.pre

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d035a47cfda4397f044828ef34ce2adfba25f4a
4
- data.tar.gz: d41409aa677dd84626738d1f3860d39acd951d72
3
+ metadata.gz: 1ab882d56754f6c3919be0df6fcac0c28f8fd636
4
+ data.tar.gz: bf5faf08f5addaef7328c3e49f042f9fcfcd5579
5
5
  SHA512:
6
- metadata.gz: f313f44d9f897fffc7bb1c3e503fdac7f6884bd3733eab89ede741a208b071207d7c7e09854fa631a00a0fde7308a6ba1753f8953211c66a55b3d53bfdac6342
7
- data.tar.gz: 01f919a66399826c5e67f05b44e86d5440e5e63b6565b5cada2980a12d24f27e296d8d10f76ec4cd1d575e927d84666afa22066eb69d7c49d76374b3cd59cae8
6
+ metadata.gz: 44411490a00f21cea8dffc48295d98055568d678431dbb6d1cf25da5d463017605c411aaf0252d7ebd9337f797d6fa5b759af3909ab8831aa402de3080ddc2a7
7
+ data.tar.gz: 477e5b5ce0fb9f72f2bc3815d58af655239f14ba7198321e3cb2800458a96d852fdca8c06d42d17bd86e197a68a616c26ea5b69b8ba7131ec7d603b15d9225ce
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
3
  /Gemfile.lock
4
+ /gemfiles/*.gemfile.lock
4
5
  /_yardoc/
5
6
  /coverage/
6
7
  /doc/
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
1
4
  ## Styles ######################################################################
2
5
 
3
6
  Style/AlignParameters:
@@ -24,6 +27,9 @@ Style/FrozenStringLiteralComment:
24
27
  Style/HashSyntax:
25
28
  EnforcedStyle: hash_rockets
26
29
 
30
+ Style/IndentArray:
31
+ EnforcedStyle: consistent
32
+
27
33
  Style/IndentHash:
28
34
  EnforcedStyle: consistent
29
35
 
data/.travis.yml CHANGED
@@ -18,6 +18,9 @@ matrix:
18
18
  - rvm: ruby-head
19
19
  - rvm: rbx-2
20
20
  fast_finish: true
21
+ gemfile:
22
+ - gemfiles/sidekiq_3.gemfile
23
+ - gemfiles/sidekiq_4.gemfile
21
24
  before_install:
22
25
  - gem install bundler -v 1.10.6
23
26
  services:
data/Appraisals ADDED
@@ -0,0 +1,8 @@
1
+ appraise "sidekiq-3" do
2
+ gem "celluloid"
3
+ gem "sidekiq", "~> 3.0"
4
+ end
5
+
6
+ appraise "sidekiq-4" do
7
+ gem "sidekiq", "~> 4.0"
8
+ end
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.3.0.pre (2016-04-25)
2
+
3
+ * [#1](https://github.com/sensortower/sidekiq-throttled/issues/1):
4
+ Add Sidekiq 4.0 support.
5
+ ([@ixti])
6
+
7
+
1
8
  ## 0.2.0 (2016-02-29)
2
9
 
3
10
  * [#6](https://github.com/sensortower/sidekiq-throttled/pull/6):
data/Gemfile CHANGED
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  source "https://rubygems.org"
3
3
 
4
+ gem "appraisal"
5
+ gem "rspec"
6
+ gem "rubocop", "~> 0.39.0"
7
+
4
8
  group :test do
5
9
  gem "coveralls"
6
10
  gem "rack-test"
7
- gem "rspec"
8
- gem "rubocop"
9
11
  gem "simplecov", ">= 0.9"
10
12
  gem "sinatra", "~> 1.4", ">= 1.4.6"
11
13
  gem "timecop"
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rspec"
7
+ gem "rubocop", "~> 0.39.0"
8
+ gem "celluloid"
9
+ gem "sidekiq", "~> 3.0"
10
+
11
+ group :test do
12
+ gem "coveralls"
13
+ gem "rack-test"
14
+ gem "simplecov", ">= 0.9"
15
+ gem "sinatra", "~> 1.4", ">= 1.4.6"
16
+ gem "timecop"
17
+ end
18
+
19
+ gemspec :path => "../"
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rspec"
7
+ gem "rubocop", "~> 0.39.0"
8
+ gem "sidekiq", "~> 4.0"
9
+
10
+ group :test do
11
+ gem "coveralls"
12
+ gem "rack-test"
13
+ gem "simplecov", ">= 0.9"
14
+ gem "sinatra", "~> 1.4", ">= 1.4.6"
15
+ gem "timecop"
16
+ end
17
+
18
+ gemspec :path => "../"
@@ -3,7 +3,7 @@
3
3
  require "thread"
4
4
 
5
5
  # 3rd party
6
- require "celluloid"
6
+ require "celluloid" if Sidekiq::VERSION < "4.0.0"
7
7
  require "sidekiq"
8
8
  require "sidekiq/fetch"
9
9
 
@@ -11,6 +11,12 @@ module Sidekiq
11
11
  module Throttled
12
12
  # Throttled version of `Sidekiq::BasicFetch` fetcher strategy.
13
13
  class BasicFetch < ::Sidekiq::BasicFetch
14
+ TIMEOUT = 2
15
+
16
+ class UnitOfWork < ::Sidekiq::BasicFetch::UnitOfWork
17
+ alias job message if Sidekiq::VERSION < "4.0.0"
18
+ end
19
+
14
20
  # Class constructor
15
21
  def initialize(*args)
16
22
  @mutex = Mutex.new
@@ -24,13 +30,13 @@ module Sidekiq
24
30
  work = brpop
25
31
  return unless work
26
32
 
27
- work = ::Sidekiq::BasicFetch::UnitOfWork.new(*work)
28
- return work unless Throttled.throttled? work.message
33
+ work = UnitOfWork.new(*work)
34
+ return work unless Throttled.throttled? work.job
29
35
 
30
36
  queue = "queue:#{work.queue_name}"
31
37
 
32
38
  @mutex.synchronize { @suspended << queue }
33
- Sidekiq.redis { |conn| conn.lpush(queue, work.message) }
39
+ Sidekiq.redis { |conn| conn.lpush(queue, work.job) }
34
40
 
35
41
  nil
36
42
  end
@@ -53,11 +59,11 @@ module Sidekiq
53
59
  end
54
60
 
55
61
  if queues.empty?
56
- sleep Sidekiq::Fetcher::TIMEOUT
62
+ sleep TIMEOUT
57
63
  return
58
64
  end
59
65
 
60
- Sidekiq.redis { |conn| conn.brpop(*queues, Sidekiq::Fetcher::TIMEOUT) }
66
+ Sidekiq.redis { |conn| conn.brpop(*queues, TIMEOUT) }
61
67
  end
62
68
  end
63
69
  end
@@ -25,16 +25,17 @@ module Sidekiq
25
25
  def initialize(name, concurrency: nil, threshold: nil, key_suffix: nil)
26
26
  key = "throttled:#{name}"
27
27
 
28
- if concurrency
29
- @concurrency = Concurrency.new(
30
- key, concurrency.merge(:key_suffix => key_suffix)
31
- )
32
- end
33
- if threshold
34
- @threshold = Threshold.new(
35
- key, threshold.merge(:key_suffix => key_suffix)
36
- )
37
- end
28
+ @concurrency =
29
+ if concurrency
30
+ concurrency[:key_suffix] = key_suffix
31
+ Concurrency.new(key, concurrency)
32
+ end
33
+
34
+ @threshold =
35
+ if threshold
36
+ threshold[:key_suffix] = key_suffix
37
+ Threshold.new(key, threshold)
38
+ end
38
39
 
39
40
  return if @concurrency || @threshold
40
41
 
@@ -2,6 +2,6 @@
2
2
  module Sidekiq
3
3
  module Throttled
4
4
  # Gem version
5
- VERSION = "0.2.0".freeze
5
+ VERSION = "0.3.0.pre".freeze
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_runtime_dependency "sidekiq", "< 4"
28
+ spec.add_runtime_dependency "sidekiq"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.10"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-throttled
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0.pre
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-02-29 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "<"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -64,12 +64,15 @@ files:
64
64
  - ".rubocop.yml"
65
65
  - ".travis.yml"
66
66
  - ".yardopts"
67
+ - Appraisals
67
68
  - CHANGES.md
68
69
  - Gemfile
69
70
  - LICENSE.md
70
71
  - README.md
71
72
  - Rakefile
72
73
  - bin/setup
74
+ - gemfiles/sidekiq_3.gemfile
75
+ - gemfiles/sidekiq_4.gemfile
73
76
  - lib/sidekiq/throttled.rb
74
77
  - lib/sidekiq/throttled/basic_fetch.rb
75
78
  - lib/sidekiq/throttled/errors.rb
@@ -103,9 +106,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
106
  version: '0'
104
107
  required_rubygems_version: !ruby/object:Gem::Requirement
105
108
  requirements:
106
- - - ">="
109
+ - - ">"
107
110
  - !ruby/object:Gem::Version
108
- version: '0'
111
+ version: 1.3.1
109
112
  requirements: []
110
113
  rubyforge_project:
111
114
  rubygems_version: 2.5.1