sidekiq-debounce 1.0.2 → 1.1.0

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: d39b6577f6d20c62c545e5361d8d7f8405700cba
4
- data.tar.gz: 6c95c2c6b5b303c738af67ccb495cb971a7cb121
3
+ metadata.gz: 78ce6184bc26dfe22fb19365d2bc8c9f7ce32ac3
4
+ data.tar.gz: 8e7a11a991cd69e828b0a75db060aa3fcd26ec62
5
5
  SHA512:
6
- metadata.gz: 9ddb67d32936dc9b0eb9d6afb205630d1ec47ee822ed3ad110b6f11ee06570fa59a23f4d7bef1acb30463d33e1628bee085b5f4224b96280dfe5fb6ec5e2ba17
7
- data.tar.gz: 59a7058d3e869c52e9cdd108cb914f6c24c60e4a9546aa23427652e06561cdf70341f3da06004e3d47726ff7caae1955b70549d12b6b1ebd41aa8ddab24b3677
6
+ metadata.gz: 56bbbefafc894a00a9177ddd9b26ad31dfdcbb2dbe0e21c2e31ae5f655d5f952d7803c762410441f3446ef71358a62dceaba060e3da999702b46330209e7b7e7
7
+ data.tar.gz: 216833ce3d6c2015d293c813bf7de30f75bd0a223934d51888df8827e3d448d9cf48a9854e97cf4328244dc2a1b379de6b7be10baab680b5ae26dfe2eb6b79b2
@@ -1,11 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.2
5
- - jruby-9.0.0.0.pre1
3
+ - 2.2.5
4
+ - 2.3.1
5
+ - jruby-9.0.1.0
6
+ - jruby-9.0.5.0
6
7
  gemfile:
8
+ - gemfiles/Gemfile.sidekiq-2.17.7
7
9
  - gemfiles/Gemfile.sidekiq-3.1.0
8
10
  - gemfiles/Gemfile.sidekiq-3.3.4
11
+ - gemfiles/Gemfile.sidekiq-4.0.2
9
12
  script: bundle exec rake test
10
13
  addons:
11
14
  code_climate:
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  Sidekiq::Debounce
2
2
  =================
3
- [![Travis CI](http://img.shields.io/travis/NuckChorris/sidekiq-debounce/master.svg)](https://travis-ci.org/NuckChorris/sidekiq-debounce)
4
- [![CodeClimate](http://img.shields.io/codeclimate/github/NuckChorris/sidekiq-debounce.svg)](https://codeclimate.com/github/NuckChorris/sidekiq-debounce)
5
- [![Coverage](http://img.shields.io/codeclimate/coverage/github/NuckChorris/sidekiq-debounce.svg)](https://codeclimate.com/github/NuckChorris/sidekiq-debounce)
3
+ [![Travis CI](http://img.shields.io/travis/hummingbird-me/sidekiq-debounce/master.svg)](https://travis-ci.org/NuckChorris/sidekiq-debounce)
4
+ [![CodeClimate](http://img.shields.io/codeclimate/github/hummingbird-me/sidekiq-debounce.svg)](https://codeclimate.com/github/NuckChorris/sidekiq-debounce)
5
+ [![Coverage](http://img.shields.io/codeclimate/coverage/github/hummingbird-me/sidekiq-debounce.svg)](https://codeclimate.com/github/NuckChorris/sidekiq-debounce)
6
6
  [![RubyGems](http://img.shields.io/gem/v/sidekiq-debounce.svg)](https://rubygems.org/gems/sidekiq-debounce)
7
- [![Gittip](http://img.shields.io/gittip/Nuck.svg)](https://www.gittip.com/Nuck/)
8
7
 
9
8
  Sidekiq::Debounce is a client-side Sidekiq middleware which provides a way to
10
9
  easily rate-limit creation of Sidekiq jobs.
@@ -40,7 +39,7 @@ Use `#perform_in` instead of `#perform_async` to set the timeframe.
40
39
 
41
40
  ## Contributing
42
41
 
43
- 1. Fork it ( https://github.com/nuckchorris/sidekiq-debounce/fork )
42
+ 1. Fork it ( https://github.com/hummingbird-me/sidekiq-debounce/fork )
44
43
  2. Create your feature branch (`git checkout -b my-new-feature`)
45
44
  3. Commit your changes (`git commit -am 'Add some feature'`)
46
45
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sidekiq', '2.17.7'
4
+
5
+ gemspec path: '../'
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sidekiq', '4.0.2'
4
+
5
+ gemspec path: '../'
@@ -3,13 +3,13 @@ require 'sidekiq/api'
3
3
 
4
4
  module Sidekiq
5
5
  class Debounce
6
- def call(worker, msg, _queue, redis_pool)
6
+ def call(worker, msg, _queue, redis_pool = nil)
7
7
  @worker = worker.is_a?(String) ? worker.constantize : worker
8
8
  @msg = msg
9
9
 
10
10
  return yield unless debounce?
11
11
 
12
- redis_pool.with do |conn|
12
+ block = Proc.new do |conn|
13
13
  # Get JID of the already-scheduled job, if there is one
14
14
  scheduled_jid = conn.get(debounce_key)
15
15
 
@@ -21,6 +21,12 @@ module Sidekiq
21
21
  return false if scheduled_jid
22
22
  jid
23
23
  end
24
+
25
+ if redis_pool
26
+ redis_pool.with(&block)
27
+ else
28
+ Sidekiq.redis(&block)
29
+ end
24
30
  end
25
31
 
26
32
  private
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  class Debounce
3
- VERSION = '1.0.2'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ calls. If you make another job with the same arguments before the specified
17
17
  time has elapsed, the timer is reset and the entire period must pass again
18
18
  before the job is executed.
19
19
  DESC
20
- spec.homepage = 'https://github.com/NuckChorris/sidekiq-debounce'
20
+ spec.homepage = 'https://github.com/hummingbird-me/sidekiq-debounce'
21
21
  spec.license = 'MIT'
22
22
 
23
23
  spec.files = `git ls-files -z`.split("\x0")
@@ -25,10 +25,11 @@ DESC
25
25
  spec.test_files = spec.files.grep(%r{^spec/})
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'sidekiq', '>= 3.1.0'
28
+ spec.add_dependency 'sidekiq', '>= 2.17'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'bundler', '~> 1.6'
31
31
  spec.add_development_dependency 'mock_redis'
32
32
  spec.add_development_dependency 'mocha'
33
33
  spec.add_development_dependency 'codeclimate-test-reporter'
34
+ spec.add_development_dependency 'minitest'
34
35
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
- require 'sidekiq/api'
3
- require 'sidekiq/debounce/middleware'
2
+ require 'sidekiq/debounce'
3
+ require 'sidekiq'
4
4
 
5
5
  class DebouncedWorker
6
6
  include Sidekiq::Worker
@@ -20,7 +20,7 @@ describe Sidekiq::Debounce do
20
20
  end
21
21
 
22
22
  let(:set) { Sidekiq::ScheduledSet.new }
23
- let(:sorted_entry) { Sidekiq::SortedEntry.new(set, 0, 'jid' => '54321') }
23
+ let(:sorted_entry) { Sidekiq::SortedEntry.new(set, 0, {jid: '54321'}.to_json) }
24
24
 
25
25
  it 'queues a job normally at first' do
26
26
  DebouncedWorker.perform_in(60, 'foo', 'bar')
@@ -9,5 +9,9 @@ Sidekiq.configure_server do |config|
9
9
  config.redis = ConnectionPool.new(size: 1) { MockRedis.new }
10
10
  end
11
11
  Sidekiq.configure_client do |config|
12
+ config.client_middleware do |chain|
13
+ chain.add Sidekiq::Debounce
14
+ end
15
+
12
16
  config.redis = ConnectionPool.new(size: 1) { MockRedis.new }
13
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-debounce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Lejeck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.0
19
+ version: '2.17'
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: 3.1.0
26
+ version: '2.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: |
98
112
  Sidekiq::Debounce provides a way to rate-limit creation of Sidekiq jobs. When
99
113
  you create a job on a Worker with debounce enabled, Sidekiq::Debounce will
@@ -116,15 +130,17 @@ files:
116
130
  - LICENSE.txt
117
131
  - README.md
118
132
  - Rakefile
133
+ - gemfiles/Gemfile.sidekiq-2.17.7
119
134
  - gemfiles/Gemfile.sidekiq-3.1.0
120
135
  - gemfiles/Gemfile.sidekiq-3.3.4
136
+ - gemfiles/Gemfile.sidekiq-4.0.2
121
137
  - lib/sidekiq/debounce.rb
122
138
  - lib/sidekiq/debounce/version.rb
123
139
  - sidekiq-debounce.gemspec
124
140
  - spec/sidekiq/debounce_spec.rb
125
141
  - spec/sidekiq_helper.rb
126
142
  - spec/spec_helper.rb
127
- homepage: https://github.com/NuckChorris/sidekiq-debounce
143
+ homepage: https://github.com/hummingbird-me/sidekiq-debounce
128
144
  licenses:
129
145
  - MIT
130
146
  metadata: {}
@@ -144,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
160
  version: '0'
145
161
  requirements: []
146
162
  rubyforge_project:
147
- rubygems_version: 2.4.6
163
+ rubygems_version: 2.5.1
148
164
  signing_key:
149
165
  specification_version: 4
150
166
  summary: A client-side middleware for debouncing Sidekiq jobs