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 +4 -4
- data/.travis.yml +3 -7
- data/lib/sidekiq/limit_fetch.rb +10 -4
- data/lib/sidekiq/limit_fetch/queues.rb +1 -1
- data/sidekiq-limit_fetch.gemspec +2 -2
- data/spec/sidekiq/limit_fetch_spec.rb +6 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca083933d1ef02f0cc4311954a1a0a8c82c9a0e0
|
4
|
+
data.tar.gz: fb76a0812ae751d02f39aeea371b37a780b6d1d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26f18118cbcf8896bf8fdf070438eb42a3f10658e6e413ed2bec88526a474857d38766bbea508b8f00081013a03ebb84eb47c1943ccd04b9150f91e11ee79df7
|
7
|
+
data.tar.gz: db1ac7268dd03b5bc28e72e9b2cef9d68e5cb606f9adb4819add906e0d2b6026d658d56d1595117955e26628eca03f05c5c4db44949f6157cac6e50c47570aa2
|
data/.travis.yml
CHANGED
data/lib/sidekiq/limit_fetch.rb
CHANGED
@@ -21,7 +21,7 @@ module Sidekiq::LimitFetch
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def retrieve_work
|
24
|
-
queue, job = redis_brpop
|
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
|
-
|
36
|
-
|
37
|
-
|
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
|
data/sidekiq-limit_fetch.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'sidekiq-limit_fetch'
|
3
|
-
gem.version = '3.1
|
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 =
|
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
|
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-
|
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.
|
140
|
+
rubygems_version: 2.5.1
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Sidekiq strategy to support queue limits
|