sidekiq-dynamic-queues 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/lib/sidekiq-dynamic-queues.rb +6 -1
- data/lib/sidekiq/dynamic_queues/fetch.rb +1 -1
- data/lib/sidekiq/dynamic_queues/version.rb +1 -1
- data/spec/queues_spec.rb +12 -3
- data/spec/spec_helper.rb +19 -18
- metadata +2 -2
data/CHANGELOG
CHANGED
data/spec/queues_spec.rb
CHANGED
@@ -240,12 +240,21 @@ describe "Dynamic Queues" do
|
|
240
240
|
SomeJob.result.should eq [2]
|
241
241
|
end
|
242
242
|
|
243
|
-
it "finds work on dynamic queue that doesn't exist till after" do
|
243
|
+
it "finds work on dynamic queue that doesn't exist till after sidekiq is waiting for jobs" do
|
244
244
|
watch_queues(*%w[default])
|
245
245
|
manager = run_queues("*", :async => true)
|
246
|
-
|
246
|
+
# give run_queues a chance to block on only the default queue given above
|
247
|
+
sleep 0.1
|
248
|
+
|
247
249
|
enqueue_on("other", SomeJob, 1)
|
248
|
-
|
250
|
+
|
251
|
+
# sidekiq brpop's with a timeout of 1, so we need to wait longer than
|
252
|
+
# that for it to re-evaluate the dynamic queues
|
253
|
+
sleep 2
|
254
|
+
timeout(5) do
|
255
|
+
manager.async.stop(:shutdown => true, :timeout => 1)
|
256
|
+
manager.wait(:shutdown)
|
257
|
+
end
|
249
258
|
SomeJob.result.should eq [1]
|
250
259
|
end
|
251
260
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'sidekiq-dynamic-queues'
|
3
|
+
require 'celluloid'
|
4
|
+
require 'sidekiq'
|
5
|
+
require 'sidekiq/fetch'
|
6
|
+
require 'sidekiq/cli'
|
7
|
+
require 'sidekiq/manager'
|
8
|
+
|
9
|
+
Sidekiq.logger.level = Logger::DEBUG
|
10
|
+
Celluloid.logger = Sidekiq.logger = nil
|
3
11
|
|
4
12
|
# No need to start redis when running in Travis
|
5
13
|
unless ENV['CI']
|
@@ -45,10 +53,6 @@ def dump_redis
|
|
45
53
|
return result
|
46
54
|
end
|
47
55
|
|
48
|
-
require 'sidekiq'
|
49
|
-
require 'celluloid'
|
50
|
-
require 'sidekiq/cli'
|
51
|
-
require 'sidekiq/manager'
|
52
56
|
|
53
57
|
Sidekiq.configure_client do |config|
|
54
58
|
config.redis = { :namespace => 'sidekiq',
|
@@ -61,9 +65,6 @@ Sidekiq.configure_server do |config|
|
|
61
65
|
:url => 'redis://localhost:6379/1' }
|
62
66
|
end
|
63
67
|
|
64
|
-
Celluloid.logger = nil
|
65
|
-
Sidekiq.logger = nil
|
66
|
-
#Celluloid.logger = Sidekiq.logger
|
67
68
|
|
68
69
|
def enqueue_on(queue, job_class, *job_args)
|
69
70
|
job_class.client_push('class' => job_class, 'args' => job_args, 'queue' => queue)
|
@@ -71,26 +72,26 @@ end
|
|
71
72
|
|
72
73
|
def run_queues(*queues)
|
73
74
|
options = queues.last.is_a?(Hash) ? queues.pop : {}
|
74
|
-
options = {:async => false, :
|
75
|
-
|
75
|
+
options = {:async => false, :timeout => 5}.merge(options)
|
76
76
|
Sidekiq::Fetcher.instance_eval { @done = false }
|
77
77
|
manager = Sidekiq::Manager.new({:queues=>queues, :concurrency=>1, :timeout=>1})
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
manager.start
|
80
|
+
|
81
|
+
unless options[:async]
|
82
|
+
# give up control so jobs can start running before we call stop
|
83
|
+
# Manager.when_done only gets called for jobs that succeed, not jobs that raise
|
84
|
+
sleep 0.1
|
85
|
+
manager.async.stop(:shutdown => true, :timeout => 1)
|
86
|
+
|
87
|
+
timeout(options[:timeout]) do
|
88
|
+
manager.wait(:shutdown)
|
85
89
|
end
|
86
90
|
end
|
87
|
-
manager.start
|
88
91
|
|
89
|
-
manager.wait(:shutdown) unless options[:async]
|
90
92
|
manager
|
91
93
|
end
|
92
94
|
|
93
|
-
|
94
95
|
class SomeJob
|
95
96
|
include Sidekiq::Worker
|
96
97
|
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: sidekiq-dynamic-queues
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matt Conway
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|