sidekiq-limit_fetch 3.1.0 → 3.2.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: 5c955908fd9f7ade4f4cd2f09f00489e6aa1416e
4
- data.tar.gz: 4b5aee7b583fa41536883e2bd00f94a71e2310af
3
+ metadata.gz: ca083933d1ef02f0cc4311954a1a0a8c82c9a0e0
4
+ data.tar.gz: fb76a0812ae751d02f39aeea371b37a780b6d1d0
5
5
  SHA512:
6
- metadata.gz: dc6a6b608540c3c206dcb36379185c76dd6e6ce017b22846dca3fb7c9d8194e73401b3d281c1e373aeb51cd4783a17af3a1581bb137e4fd144a6ad070f348186
7
- data.tar.gz: ee479c98a4e448ad29c9edb3ae1f8fe536b1fc8fca61e2713d206ae614d2cd3786fa784c8b123086bf60afdc7cdda149c35a6bb4d075b2fd52f6678f68191971
6
+ metadata.gz: 26f18118cbcf8896bf8fdf070438eb42a3f10658e6e413ed2bec88526a474857d38766bbea508b8f00081013a03ebb84eb47c1943ccd04b9150f91e11ee79df7
7
+ data.tar.gz: db1ac7268dd03b5bc28e72e9b2cef9d68e5cb606f9adb4819add906e0d2b6026d658d56d1595117955e26628eca03f05c5c4db44949f6157cac6e50c47570aa2
@@ -1,11 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
4
- - 2.2.1
5
- - jruby-head
6
- - rbx-2
3
+ - 2.3
4
+ - 2.2
5
+ - jruby
7
6
  services:
8
7
  - redis-server
9
- matrix:
10
- allow_failures:
11
- - rvm: rbx-2
@@ -21,7 +21,7 @@ module Sidekiq::LimitFetch
21
21
  end
22
22
 
23
23
  def retrieve_work
24
- queue, job = redis_brpop *Queues.acquire, Sidekiq::BasicFetch::TIMEOUT
24
+ queue, job = redis_brpop(Queues.acquire)
25
25
  Queues.release_except(queue)
26
26
  UnitOfWork.new(queue, job) if job
27
27
  end
@@ -32,8 +32,14 @@ module Sidekiq::LimitFetch
32
32
 
33
33
  private
34
34
 
35
- def redis_brpop(*args)
36
- return if args.size < 2
37
- Sidekiq.redis {|it| it.brpop *args }
35
+ TIMEOUT = Sidekiq::BasicFetch::TIMEOUT
36
+
37
+ def redis_brpop(queues)
38
+ if queues.empty?
39
+ sleep TIMEOUT # there are no queues to handle, so lets sleep
40
+ [] # and return nothing
41
+ else
42
+ Sidekiq.redis { |it| it.brpop *queues, TIMEOUT }
43
+ end
38
44
  end
39
45
  end
@@ -48,7 +48,7 @@ module Sidekiq::LimitFetch::Queues
48
48
  def namespace
49
49
  @namespace ||= Sidekiq.redis do |it|
50
50
  if it.respond_to?(:namespace) and it.namespace
51
- it.namespace + ':'
51
+ "#{it.namespace}:"
52
52
  else
53
53
  ''
54
54
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '3.1.0'
3
+ gem.version = '3.2.1'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = 'brainopia'
6
6
  gem.email = 'brainopia@evilmartians.com'
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
 
14
14
  gem.files = `git ls-files`.split($/)
15
15
  gem.test_files = gem.files.grep %r{^spec/}
16
- gem.require_paths = 'lib'
16
+ gem.require_paths = %w(lib)
17
17
 
18
18
  gem.add_dependency 'sidekiq', '>= 4'
19
19
  gem.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
@@ -1,7 +1,13 @@
1
1
  Thread.abort_on_exception = true
2
2
 
3
3
  RSpec.describe Sidekiq::LimitFetch do
4
+ let(:options) {{ queues: queues, limits: limits }}
5
+ let(:queues) { %w(queue1 queue1 queue2 queue2) }
6
+ let(:limits) {{ 'queue1' => 1, 'queue2' => 2 }}
7
+
4
8
  before do
9
+ subject::Queues.start options
10
+
5
11
  Sidekiq.redis do |it|
6
12
  it.del 'queue:queue1'
7
13
  it.lpush 'queue:queue1', 'task1'
@@ -10,12 +16,6 @@ RSpec.describe Sidekiq::LimitFetch do
10
16
  end
11
17
  end
12
18
 
13
- let(:options) {{ queues: queues, limits: limits }}
14
- let(:queues) { %w(queue1 queue1 queue2 queue2) }
15
- let(:limits) {{ 'queue1' => 1, 'queue2' => 2 }}
16
-
17
- before { subject::Queues.start options }
18
-
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'
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.1.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.4.5.1
140
+ rubygems_version: 2.5.1
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Sidekiq strategy to support queue limits