sidekiq-limit_fetch 0.9 → 1.0
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.
- data/README.md +7 -1
- data/lib/sidekiq/limit_fetch/queues.rb +11 -5
- data/sidekiq-limit_fetch.gemspec +1 -1
- data/spec/sidekiq/limit_fetch/queues_spec.rb +18 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -67,6 +67,12 @@ enable global mode by setting global option, eg:
|
|
67
67
|
:global: true
|
68
68
|
```
|
69
69
|
|
70
|
+
or
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Sidekiq.options[:global] = true
|
74
|
+
```
|
75
|
+
|
70
76
|
|
71
77
|
If you use strict queue ordering (it will be used if you don't specify queue weights)
|
72
78
|
then you can set blocking status for queues. It means if a blocking
|
@@ -78,7 +84,7 @@ be ran. Eg,
|
|
78
84
|
- a
|
79
85
|
- b
|
80
86
|
- c
|
81
|
-
:
|
87
|
+
:blocking:
|
82
88
|
- b
|
83
89
|
```
|
84
90
|
|
@@ -9,6 +9,7 @@ class Sidekiq::LimitFetch
|
|
9
9
|
|
10
10
|
set_selector options[:global]
|
11
11
|
set_limits options[:limits]
|
12
|
+
set_blocks options[:blocking]
|
12
13
|
end
|
13
14
|
|
14
15
|
def acquire
|
@@ -16,7 +17,7 @@ class Sidekiq::LimitFetch
|
|
16
17
|
.tap {|it| save it }
|
17
18
|
.map {|it| "queue:#{it}" }
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
def release_except(full_name)
|
21
22
|
@selector.release restore.delete_if {|name| full_name.to_s.include? name }
|
22
23
|
end
|
@@ -28,10 +29,15 @@ class Sidekiq::LimitFetch
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def set_limits(limits)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
return unless limits
|
33
|
+
limits.each do |name, limit|
|
34
|
+
Sidekiq::Queue[name].limit = limit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_blocks(blocks)
|
39
|
+
blocks.to_a.each do |name|
|
40
|
+
Sidekiq::Queue[name].block
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
data/sidekiq-limit_fetch.gemspec
CHANGED
@@ -7,9 +7,14 @@ describe Sidekiq::LimitFetch::Queues do
|
|
7
7
|
let(:limits) {{ 'queue1' => 3 }}
|
8
8
|
let(:strict) { true }
|
9
9
|
let(:global) { false }
|
10
|
+
let(:blocking) { nil }
|
10
11
|
|
11
12
|
let(:options) do
|
12
|
-
{ queues: queues,
|
13
|
+
{ queues: queues,
|
14
|
+
limits: limits,
|
15
|
+
strict: strict,
|
16
|
+
global: global,
|
17
|
+
blocking: blocking }
|
13
18
|
end
|
14
19
|
|
15
20
|
after(:each ) do
|
@@ -23,7 +28,7 @@ describe Sidekiq::LimitFetch::Queues do
|
|
23
28
|
Sidekiq::Queue['queue2'].busy.should == 1
|
24
29
|
end
|
25
30
|
|
26
|
-
it 'should acquire blocking queues' do
|
31
|
+
it 'should acquire dynamically blocking queues' do
|
27
32
|
subject.acquire
|
28
33
|
Sidekiq::Queue['queue1'].busy.should == 1
|
29
34
|
Sidekiq::Queue['queue2'].busy.should == 1
|
@@ -48,8 +53,18 @@ describe Sidekiq::LimitFetch::Queues do
|
|
48
53
|
Sidekiq::Queue['queue1'].busy.should == 1
|
49
54
|
Sidekiq::Queue['queue2'].busy.should == 0
|
50
55
|
end
|
56
|
+
|
57
|
+
context 'blocking' do
|
58
|
+
let(:blocking) { %w(queue1) }
|
59
|
+
|
60
|
+
it 'should acquire blocking queues' do
|
61
|
+
3.times { subject.acquire }
|
62
|
+
Sidekiq::Queue['queue1'].busy.should == 3
|
63
|
+
Sidekiq::Queue['queue2'].busy.should == 1
|
64
|
+
end
|
65
|
+
end
|
51
66
|
end
|
52
|
-
|
67
|
+
|
53
68
|
context 'without global flag' do
|
54
69
|
it_should_behave_like :selector
|
55
70
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-limit_fetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash: -
|
112
|
+
hash: -2462116291235109509
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
none: false
|
115
115
|
requirements:
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
segments:
|
120
120
|
- 0
|
121
|
-
hash: -
|
121
|
+
hash: -2462116291235109509
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
124
|
rubygems_version: 1.8.24
|