sidekiq-limit_fetch 2.2.7 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/sidekiq/limit_fetch.rb +1 -1
- data/lib/sidekiq/limit_fetch/global/monitor.rb +8 -3
- data/lib/sidekiq/limit_fetch/queues.rb +12 -1
- data/sidekiq-limit_fetch.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f61efe790fd1a000679bad6e455f85276bd348f1
|
4
|
+
data.tar.gz: 03db81df3adfa998e350dd2e80a12c09b9a90091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd35d8ec8c170ba465e1037374daf169828aca0a611c3e0ad4be5385aa0feead331173a383104f879b838406925c54d5b399c3bb20a79def97e05dd011be59cc
|
7
|
+
data.tar.gz: cf389b01004b864384ab9f4b1b15bcf951e050ec4f83b1fc3e098251f8b640be5018c4f797690fcc14363d9448f152d2f69c7c58d978da2d44f2a36b4c336146
|
data/README.md
CHANGED
@@ -132,6 +132,20 @@ You can dynamically set exceptions for queue blocking:
|
|
132
132
|
Sidekiq::Queue['queue1'].block_except 'queue2'
|
133
133
|
```
|
134
134
|
|
135
|
+
### Dynamic queues
|
136
|
+
|
137
|
+
You can support dynamic queues (that are not listed in sidekiq.yml but
|
138
|
+
that have tasks pushed to them (usually with `Sidekiq::Client.push`)).
|
139
|
+
|
140
|
+
To use this mode you need to specify a following line in sidekiq.yml:
|
141
|
+
|
142
|
+
```yaml
|
143
|
+
:dynamic: true
|
144
|
+
```
|
145
|
+
|
146
|
+
Dynamic queues will be ran at the lowest priority.
|
147
|
+
|
148
|
+
|
135
149
|
### Thanks
|
136
150
|
|
137
151
|
Sponsored by [Evil Martians].
|
data/lib/sidekiq/limit_fetch.rb
CHANGED
@@ -5,12 +5,13 @@ module Sidekiq::LimitFetch::Global
|
|
5
5
|
|
6
6
|
HEARTBEAT_PREFIX = 'limit:heartbeat:'
|
7
7
|
PROCESS_SET = 'limit:processes'
|
8
|
-
HEARTBEAT_TTL =
|
9
|
-
REFRESH_TIMEOUT =
|
8
|
+
HEARTBEAT_TTL = 20
|
9
|
+
REFRESH_TIMEOUT = 5
|
10
10
|
|
11
|
-
def start!(ttl=HEARTBEAT_TTL, timeout=REFRESH_TIMEOUT)
|
11
|
+
def start!(queues, ttl=HEARTBEAT_TTL, timeout=REFRESH_TIMEOUT)
|
12
12
|
Thread.new do
|
13
13
|
loop do
|
14
|
+
add_dynamic queues if queues.dynamic?
|
14
15
|
update_heartbeat ttl
|
15
16
|
invalidate_old_processes
|
16
17
|
sleep timeout
|
@@ -34,6 +35,10 @@ module Sidekiq::LimitFetch::Global
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
def add_dynamic(queues)
|
39
|
+
queues.add Sidekiq::Queue.all.map(&:name)
|
40
|
+
end
|
41
|
+
|
37
42
|
private
|
38
43
|
|
39
44
|
def update_heartbeat(ttl)
|
@@ -5,6 +5,7 @@ class Sidekiq::LimitFetch
|
|
5
5
|
def initialize(options)
|
6
6
|
@queues = options[:queues]
|
7
7
|
@namespace = options[:namespace]
|
8
|
+
@dynamic = options[:dynamic]
|
8
9
|
|
9
10
|
options[:strict] ? strict_order! : weighted_order!
|
10
11
|
|
@@ -25,6 +26,16 @@ class Sidekiq::LimitFetch
|
|
25
26
|
selector.release queues, @namespace
|
26
27
|
end
|
27
28
|
|
29
|
+
def dynamic?
|
30
|
+
@dynamic
|
31
|
+
end
|
32
|
+
|
33
|
+
def add(queues)
|
34
|
+
queues.each do |queue|
|
35
|
+
@queues.push queue unless @queues.include? queue
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
private
|
29
40
|
|
30
41
|
def selector
|
@@ -69,7 +80,7 @@ class Sidekiq::LimitFetch
|
|
69
80
|
ensure
|
70
81
|
Thread.current[THREAD_KEY] = nil
|
71
82
|
end
|
72
|
-
|
83
|
+
|
73
84
|
def each_queue
|
74
85
|
@queues.uniq.each {|it| yield Sidekiq::Queue[it] }
|
75
86
|
end
|
data/sidekiq-limit_fetch.gemspec
CHANGED