sidekiq-limit_fetch 3.0.1 → 3.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: 35782b40e123ecb5150daf62de8e271d135b0b40
4
- data.tar.gz: a690354bc035c32d6c976ad1f355aa67d7f82689
3
+ metadata.gz: 5c955908fd9f7ade4f4cd2f09f00489e6aa1416e
4
+ data.tar.gz: 4b5aee7b583fa41536883e2bd00f94a71e2310af
5
5
  SHA512:
6
- metadata.gz: c615557f879fb2c49a286d005335199d80d96326a38786ae784bfc73f645687966b111c4cc5e11d238a1d0eb25ed65759cb45b259a5df3cf0a81af55b30b4b19
7
- data.tar.gz: 1b1d747d357512c22a56729cc111e852c9317bb3d0078746d4b31d74118c53f16f52a2bb3e9e05a705203a2f3aa8e02ac82c7da2797b9313f48f26598d012f2a
6
+ metadata.gz: dc6a6b608540c3c206dcb36379185c76dd6e6ce017b22846dca3fb7c9d8194e73401b3d281c1e373aeb51cd4783a17af3a1581bb137e4fd144a6ad070f348186
7
+ data.tar.gz: ee479c98a4e448ad29c9edb3ae1f8fe536b1fc8fca61e2713d206ae614d2cd3786fa784c8b123086bf60afdc7cdda149c35a6bb4d075b2fd52f6678f68191971
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.3.0
3
4
  - 2.2.1
4
5
  - jruby-head
5
6
  - rbx-2
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem 'sidekiq', github: 'mperham/sidekiq', branch: 'internal_rewrite'
4
+ gem 'sidekiq'
data/README.md CHANGED
@@ -16,15 +16,11 @@ Add this line to your application's Gemfile:
16
16
 
17
17
  ### Requirements
18
18
 
19
- redis 2.6 or newer
20
-
21
19
  **Important note:** At this moment, `sidekiq-limit_fetch` is incompatible with
22
20
  - sidekiq pro's `reliable_fetch`
23
21
  - `sidekiq-rate-limiter`
24
22
  - any other plugin that rewrites fetch strategy of sidekiq.
25
23
 
26
- https://github.com/mperham/sidekiq/issues/1508 — a sidekiq admin busy page is unreliable, so if you need to check how many workers are running a queue use a `#busy` method described below.
27
-
28
24
  ## Usage
29
25
 
30
26
  ### Limits
@@ -21,9 +21,9 @@ module Sidekiq::LimitFetch
21
21
  end
22
22
 
23
23
  def retrieve_work
24
- queue, message = redis_brpop *Queues.acquire, Sidekiq::BasicFetch::TIMEOUT
25
- Queues.release_except queue
26
- UnitOfWork.new queue, message if message
24
+ queue, job = redis_brpop *Queues.acquire, Sidekiq::BasicFetch::TIMEOUT
25
+ Queues.release_except(queue)
26
+ UnitOfWork.new(queue, job) if job
27
27
  end
28
28
 
29
29
  def bulk_requeue(*args)
@@ -2,6 +2,8 @@ module Sidekiq::LimitFetch::Global
2
2
  module Selector
3
3
  extend self
4
4
 
5
+ MUTEX_FOR_UUID = Mutex.new
6
+
5
7
  def acquire(queues, namespace)
6
8
  redis_eval :acquire, [namespace, uuid, queues]
7
9
  end
@@ -15,9 +17,7 @@ module Sidekiq::LimitFetch::Global
15
17
  # then @uuid can be overwritten
16
18
  # - if we'll remove "@uuid ||=" from outside of mutex
17
19
  # then each read will lead to mutex
18
- @uuid ||= Thread.exclusive do
19
- @uuid || SecureRandom.uuid
20
- end
20
+ @uuid ||= MUTEX_FOR_UUID.synchronize { @uuid || SecureRandom.uuid }
21
21
  end
22
22
 
23
23
  private
@@ -1,6 +1,6 @@
1
1
  module Sidekiq
2
2
  class LimitFetch::UnitOfWork < BasicFetch::UnitOfWork
3
- def initialize(queue, message)
3
+ def initialize(queue, job)
4
4
  super
5
5
  Queue[queue_name].increase_busy
6
6
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '3.0.1'
3
+ gem.version = '3.1.0'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = 'brainopia'
6
6
  gem.email = 'brainopia@evilmartians.com'
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = 'lib'
17
17
 
18
18
  gem.add_dependency 'sidekiq', '>= 4'
19
+ gem.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
19
20
  gem.add_development_dependency 'rspec'
20
21
  gem.add_development_dependency 'rake'
21
22
  end
@@ -19,7 +19,7 @@ RSpec.describe Sidekiq::LimitFetch do
19
19
  it 'should acquire lock on queue for execution' do
20
20
  work = subject.retrieve_work
21
21
  expect(work.queue_name).to eq 'queue1'
22
- expect(work.message).to eq 'task1'
22
+ expect(work.job).to eq 'task1'
23
23
 
24
24
  expect(Sidekiq::Queue['queue1'].busy).to eq 1
25
25
  expect(Sidekiq::Queue['queue2'].busy).to eq 0
@@ -31,7 +31,7 @@ RSpec.describe Sidekiq::LimitFetch do
31
31
  expect(Sidekiq::Queue['queue2'].busy).to eq 0
32
32
 
33
33
  work = subject.retrieve_work
34
- expect(work.message).to eq 'task1'
34
+ expect(work.job).to eq 'task1'
35
35
 
36
36
  expect(Sidekiq::Queue['queue1'].busy).to eq 1
37
37
  expect(Sidekiq::Queue['queue2'].busy).to eq 0
@@ -43,6 +43,6 @@ RSpec.describe Sidekiq::LimitFetch do
43
43
  expect(Sidekiq::Queue['queue2'].busy).to eq 0
44
44
 
45
45
  work = subject.retrieve_work
46
- expect(work.message).to eq 'task2'
46
+ expect(work.job).to eq 'task2'
47
47
  end
48
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-limit_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis-namespace
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.5.2
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.5'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.5.2
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: rspec
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
137
  version: '0'
118
138
  requirements: []
119
139
  rubyforge_project:
120
- rubygems_version: 2.4.5
140
+ rubygems_version: 2.4.5.1
121
141
  signing_key:
122
142
  specification_version: 4
123
143
  summary: Sidekiq strategy to support queue limits