sidekiq-limit_fetch 1.4 → 1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -17
- data/lib/sidekiq/extensions/queue.rb +1 -1
- data/lib/sidekiq/limit_fetch/queues.rb +3 -3
- data/lib/sidekiq/limit_fetch.rb +1 -1
- data/sidekiq-limit_fetch.gemspec +1 -1
- data/spec/sidekiq/extensions/queue_spec.rb +2 -2
- data/spec/sidekiq/limit_fetch/global/monitor_spec.rb +11 -1
- data/spec/sidekiq/limit_fetch/queues_spec.rb +16 -16
- data/spec/sidekiq/limit_fetch_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c530f12f2c18dba1c729e6271112081154a78b7f
|
4
|
+
data.tar.gz: 0d9a6695cad3ec9965a2629ef8e8b83b171bcb8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30851e2e580ae34f6e2a67d7fe6a44397e723a9811377d0afb4defc2a04ea821a5b498b16df70666558f04070923e1549f0c4e4a4633110a0f2d3b13b67c9dee
|
7
|
+
data.tar.gz: f445df4cec59bf1773f9947eb3fd76b5e19eeacba7e73a6136bcd99828bd94dd2fe3c2ac48a60f2e3d6deb371add6251b55273e5a49883790e1e840581a2bb5e
|
data/README.md
CHANGED
@@ -58,23 +58,6 @@ will be preserved.
|
|
58
58
|
Sidekiq::Queue['name'].unpause # allows workers to use the queue
|
59
59
|
```
|
60
60
|
|
61
|
-
### Multiple processes
|
62
|
-
|
63
|
-
Limits are applied per process. In case you have several worker
|
64
|
-
processes and want to have global locks between them, you'll need to
|
65
|
-
enable global mode by setting global option, eg:
|
66
|
-
|
67
|
-
```yaml
|
68
|
-
:global: true
|
69
|
-
```
|
70
|
-
|
71
|
-
or
|
72
|
-
|
73
|
-
```ruby
|
74
|
-
Sidekiq.options[:global] = true
|
75
|
-
```
|
76
|
-
|
77
|
-
|
78
61
|
### Blocking queue mode
|
79
62
|
|
80
63
|
If you use strict queue ordering (it will be used if you don't specify queue weights)
|
@@ -7,7 +7,7 @@ class Sidekiq::LimitFetch
|
|
7
7
|
@queues = options[:queues]
|
8
8
|
options[:strict] ? strict_order! : weighted_order!
|
9
9
|
|
10
|
-
set_selector options[:
|
10
|
+
set_selector options[:local]
|
11
11
|
set_limits options[:limits]
|
12
12
|
set_blocks options[:blocking]
|
13
13
|
end
|
@@ -26,8 +26,8 @@ class Sidekiq::LimitFetch
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def set_selector(
|
30
|
-
@selector =
|
29
|
+
def set_selector(local)
|
30
|
+
@selector = local ? Local::Selector : Global::Selector
|
31
31
|
end
|
32
32
|
|
33
33
|
def set_limits(limits)
|
data/lib/sidekiq/limit_fetch.rb
CHANGED
data/sidekiq-limit_fetch.gemspec
CHANGED
@@ -88,12 +88,12 @@ describe Sidekiq::Queue do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'global' do
|
91
|
-
before(:all) { Sidekiq.options[:
|
91
|
+
before(:all) { Sidekiq.options[:local] = false }
|
92
92
|
it_behaves_like :lock
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'local' do
|
96
|
-
before(:all) { Sidekiq.options[:
|
96
|
+
before(:all) { Sidekiq.options[:local] = true }
|
97
97
|
it_behaves_like :lock
|
98
98
|
end
|
99
99
|
end
|
@@ -1,13 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Sidekiq::LimitFetch::Global::Monitor do
|
4
|
-
let(:global) { true }
|
5
4
|
let(:monitor) { described_class.start! ttl, timeout }
|
6
5
|
let(:ttl) { 1 }
|
7
6
|
let(:queue) { Sidekiq::Queue[name] }
|
8
7
|
let(:name) { 'default' }
|
9
8
|
|
10
9
|
before :each do
|
10
|
+
# namespaces = [
|
11
|
+
# described_class::PROCESSOR_NAMESPACE,
|
12
|
+
# described_class::HEARTBEAT_NAMESPACE
|
13
|
+
# ]
|
14
|
+
|
15
|
+
# Sidekiq.redis do |it|
|
16
|
+
# namespaces.flat_map {|namespace|
|
17
|
+
# it.keys(namespace + '*')
|
18
|
+
# }.each {|key| it.del key }
|
19
|
+
# end
|
20
|
+
|
11
21
|
monitor
|
12
22
|
end
|
13
23
|
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Sidekiq::LimitFetch::Queues do
|
4
4
|
subject { described_class.new options }
|
5
5
|
|
6
|
-
let(:queues)
|
7
|
-
let(:limits)
|
8
|
-
let(:strict)
|
9
|
-
let(:
|
10
|
-
let(:blocking) {
|
6
|
+
let(:queues) { %w[queue1 queue2] }
|
7
|
+
let(:limits) {{ 'queue1' => 3 }}
|
8
|
+
let(:strict) { true }
|
9
|
+
let(:local) {}
|
10
|
+
let(:blocking) {}
|
11
11
|
|
12
12
|
let(:options) do
|
13
|
-
{ queues:
|
14
|
-
limits:
|
15
|
-
strict:
|
16
|
-
|
13
|
+
{ queues: queues,
|
14
|
+
limits: limits,
|
15
|
+
strict: strict,
|
16
|
+
local: local,
|
17
17
|
blocking: blocking }
|
18
18
|
end
|
19
19
|
|
@@ -83,20 +83,20 @@ describe Sidekiq::LimitFetch::Queues do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
context 'without
|
86
|
+
context 'without local flag' do
|
87
87
|
it_should_behave_like :selector
|
88
88
|
|
89
|
-
it 'without
|
90
|
-
subject.selector.should == Sidekiq::LimitFetch::
|
89
|
+
it 'without local flag should be global' do
|
90
|
+
subject.selector.should == Sidekiq::LimitFetch::Global::Selector
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
context 'with
|
95
|
-
let(:
|
94
|
+
context 'with local flag' do
|
95
|
+
let(:local) { true }
|
96
96
|
it_should_behave_like :selector
|
97
97
|
|
98
|
-
it 'should use
|
99
|
-
subject.selector.should == Sidekiq::LimitFetch::
|
98
|
+
it 'should use local selector' do
|
99
|
+
subject.selector.should == Sidekiq::LimitFetch::Local::Selector
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -11,7 +11,7 @@ describe Sidekiq::LimitFetch do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
subject { described_class.new options }
|
14
|
-
let(:options) {{ queues: queues, limits: limits,
|
14
|
+
let(:options) {{ queues: queues, limits: limits, local: local }}
|
15
15
|
let(:queues) { %w(queue1 queue1 queue2 queue2) }
|
16
16
|
let(:limits) {{ 'queue1' => 1, 'queue2' => 2 }}
|
17
17
|
|
@@ -36,12 +36,12 @@ describe Sidekiq::LimitFetch do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'global' do
|
39
|
-
let(:
|
39
|
+
let(:local) { false }
|
40
40
|
it_behaves_like :strategy
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'local' do
|
44
|
-
let(:
|
44
|
+
let(:local) { true }
|
45
45
|
it_behaves_like :strategy
|
46
46
|
end
|
47
47
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,8 +3,8 @@ require 'sidekiq/limit_fetch'
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
config.before :each do
|
5
5
|
Sidekiq::Queue.instance_variable_set :@instances, {}
|
6
|
-
Sidekiq.options[:
|
7
|
-
|
6
|
+
Sidekiq.options[:local] = defined?(local) ? local : nil
|
7
|
+
|
8
8
|
Sidekiq.redis do |it|
|
9
9
|
clean_redis = ->(queue) do
|
10
10
|
it.del "limit_fetch:limit:#{queue}"
|
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: '1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brainopia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|