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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/README.md +0 -4
- data/lib/sidekiq/limit_fetch.rb +3 -3
- data/lib/sidekiq/limit_fetch/global/selector.rb +3 -3
- data/lib/sidekiq/limit_fetch/unit_of_work.rb +1 -1
- data/sidekiq-limit_fetch.gemspec +2 -1
- data/spec/sidekiq/limit_fetch_spec.rb +3 -3
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c955908fd9f7ade4f4cd2f09f00489e6aa1416e
|
4
|
+
data.tar.gz: 4b5aee7b583fa41536883e2bd00f94a71e2310af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6a6b608540c3c206dcb36379185c76dd6e6ce017b22846dca3fb7c9d8194e73401b3d281c1e373aeb51cd4783a17af3a1581bb137e4fd144a6ad070f348186
|
7
|
+
data.tar.gz: ee479c98a4e448ad29c9edb3ae1f8fe536b1fc8fca61e2713d206ae614d2cd3786fa784c8b123086bf60afdc7cdda149c35a6bb4d075b2fd52f6678f68191971
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
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
|
data/lib/sidekiq/limit_fetch.rb
CHANGED
@@ -21,9 +21,9 @@ module Sidekiq::LimitFetch
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def retrieve_work
|
24
|
-
queue,
|
25
|
-
Queues.release_except
|
26
|
-
UnitOfWork.new
|
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 ||=
|
19
|
-
@uuid || SecureRandom.uuid
|
20
|
-
end
|
20
|
+
@uuid ||= MUTEX_FOR_UUID.synchronize { @uuid || SecureRandom.uuid }
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
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.0
|
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.
|
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.
|
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.
|
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
|
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:
|
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
|