lib/backgrounder/support/backends.rb in carrierwave_backgrounder-0.4.1 vs lib/backgrounder/support/backends.rb in carrierwave_backgrounder-0.4.2
- old
+ new
@@ -21,14 +21,18 @@
end
private
def enqueue_delayed_job(worker, *args)
+ worker_args = {}
if ::Delayed::Job.new.respond_to?(:queue)
- ::Delayed::Job.enqueue worker.new(*args), :queue => queue_options[:queue]
+ worker_args[:queue] = queue_options[:queue] if queue_options[:queue]
+ worker_args[:priority] = queue_options[:priority] if queue_options[:priority]
+ ::Delayed::Job.enqueue worker.new(*args), worker_args
else
- ::Delayed::Job.enqueue worker.new(*args)
+ worker_args[:priority] = queue_options[:priority] if queue_options[:priority]
+ ::Delayed::Job.enqueue worker.new(*args), worker_args
if queue_options[:queue]
::Rails.logger.warn("Queue name given but no queue column exists for Delayed::Job")
end
end
end
@@ -37,11 +41,12 @@
worker.instance_variable_set('@queue', queue_options[:queue] || :carrierwave)
::Resque.enqueue worker, *args
end
def enqueue_sidekiq(worker, *args)
- args = sidekiq_queue_options('class' => worker, 'args' => args)
+ override_queue_name = worker.sidekiq_options['queue'] == 'default' || worker.sidekiq_options['queue'].nil?
+ args = sidekiq_queue_options(override_queue_name, 'class' => worker, 'args' => args)
worker.client_push(args)
end
def enqueue_girl_friday(worker, *args)
@girl_friday_queue ||= GirlFriday::WorkQueue.new(queue_options.delete(:queue) || :carrierwave, queue_options) do |msg|
@@ -67,11 +72,13 @@
def enqueue_immediate(worker, *args)
worker.new(*args).perform
end
- def sidekiq_queue_options(args)
- args['queue'] = queue_options[:queue] if queue_options[:queue]
+ def sidekiq_queue_options(override_queue_name, args)
+ if override_queue_name && queue_options[:queue]
+ args['queue'] = queue_options[:queue]
+ end
args['retry'] = queue_options[:retry] unless queue_options[:retry].nil?
args['timeout'] = queue_options[:timeout] if queue_options[:timeout]
args['backtrace'] = queue_options[:backtrace] if queue_options[:backtrace]
args
end