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 CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.5 (06/13/2013)
2
+ ------------------
3
+
4
+ fix celluloid dependency bug <280892e> [Michael Wu]
5
+ fix integration tests <c715333> [Matt Conway]
6
+
1
7
  0.5.4
2
8
  -----
3
9
 
@@ -1,3 +1,8 @@
1
1
  require 'sidekiq'
2
2
  require 'sidekiq/dynamic_queues/attributes'
3
- require 'sidekiq/dynamic_queues/fetch'
3
+
4
+ module Sidekiq
5
+ module DynamicQueues
6
+ autoload :Fetch, 'sidekiq/dynamic_queues/fetch'
7
+ end
8
+ end
@@ -1,4 +1,4 @@
1
- require 'sidekiq/fetch'
1
+ require 'forwardable'
2
2
 
3
3
  module Sidekiq
4
4
  module DynamicQueues
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module DynamicQueues
3
- VERSION = "0.5.4"
3
+ VERSION = "0.5.5"
4
4
  end
5
5
  end
@@ -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
- sleep 0.2
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
- manager.wait(:shutdown)
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
 
@@ -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, :job_count => 1}.merge(options)
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
- job_count = 0
80
- manager.when_done do
81
- job_count += 1
82
- yield if block_given?
83
- if job_count >= options[:job_count].to_i
84
- manager.stop(:shutdown => true, :timeout => 0)
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.4
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-04-09 00:00:00.000000000 Z
12
+ date: 2013-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq