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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f52435a3183c00620d7608d66cb14abc322515bd
4
- data.tar.gz: bcf1864897a35521852a9a65394a8f7779ff810d
3
+ metadata.gz: f61efe790fd1a000679bad6e455f85276bd348f1
4
+ data.tar.gz: 03db81df3adfa998e350dd2e80a12c09b9a90091
5
5
  SHA512:
6
- metadata.gz: 3c0bc6f01d9899b2e9af4835f575e8ec687fb7d655a29ae62e9661807951cba194121afe3f0716e57b7fdb165e129ae6b4ab00f12cd230a2f6d70c047e2c0b6f
7
- data.tar.gz: 2969c1b38d2cd6df5edfb74382bb983fe6abbb712d81e04b0d6751ffe09bd06bfada506845351dd98a8982ed27a6e2550d1579455af31fc8b7c7851b6d324b3a
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].
@@ -22,8 +22,8 @@ class Sidekiq::LimitFetch
22
22
  end
23
23
 
24
24
  def initialize(options)
25
- Global::Monitor.start!
26
25
  @queues = Queues.new options.merge(namespace: determine_namespace)
26
+ Global::Monitor.start! @queues
27
27
  end
28
28
 
29
29
  def retrieve_work
@@ -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 = 18
9
- REFRESH_TIMEOUT = 10
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '2.2.7'
3
+ gem.version = '2.3.0'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = 'brainopia'
6
6
  gem.email = 'brainopia@evilmartians.com'
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: 2.2.7
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia