diff --git a/lib/queue_classic.rb b/lib/queue_classic.rb index dc037f16..9c6d6d18 100644 --- a/lib/queue_classic.rb +++ b/lib/queue_classic.rb @@ -18,7 +18,7 @@ module QC # notes the queue. You can point your workers # at different queues but only one at a time. QUEUE = ENV["QUEUE"] || "default" - QUEUES = ENV["QUEUES"] || [] + QUEUES = (ENV["QUEUES"] && ENV["QUEUES"].split(",")) || [] # Set this to 1 for strict FIFO. # There is nothing special about 9.... diff --git a/lib/queue_classic/worker.rb b/lib/queue_classic/worker.rb index c03628db..ea8814ec 100644 --- a/lib/queue_classic/worker.rb +++ b/lib/queue_classic/worker.rb @@ -21,7 +21,9 @@ def initialize(args={}) @wait_interval = args[:wait_interval] || QC::WAIT_TIME @conn_adapter = ConnAdapter.new(args[:connection]) @queues = setup_queues(@conn_adapter, - args[:q_name], args[:q_names], args[:top_bound]) + (args[:q_name] || QC::QUEUE), + (args[:q_names] || QC::QUEUES), + (args[:top_bound] || QC::TOP_BOUND)) log(args.merge(:at => "worker_initialized")) @running = true end @@ -131,10 +133,8 @@ def log(data) private - def setup_queues(adapter, q_name, q_names, top_bound) - name = q_name || QC::QUEUE - names = q_names || QC::QUEUES - names << name unless names.include?(name) + def setup_queues(adapter, queue, queues, top_bound) + names = queues.length > 0 ? queues : [queue] names.map do |name| QC::Queue.new(name, top_bound).tap do |q| q.conn_adapter = adapter