1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

initialize queue names only once

This commit is contained in:
Ryan LeCompte 2012-04-03 20:38:03 -07:00
parent c66d58a235
commit a72d3185c1

View file

@ -15,7 +15,7 @@ module Sidekiq
def initialize(mgr, queues) def initialize(mgr, queues)
@mgr = mgr @mgr = mgr
@queues = queues @queues = queues.map { |q| "queue:#{q}" }
@num_queues = queues.uniq.size @num_queues = queues.uniq.size
end end
@ -49,8 +49,7 @@ module Sidekiq
# recreate the queue command each time we invoke Redis#blpop # recreate the queue command each time we invoke Redis#blpop
# to honor weights and avoid queue starvation. # to honor weights and avoid queue starvation.
def queues_cmd def queues_cmd
queues = @queues.sample(@num_queues) cmd = @queues.sample(@num_queues)
cmd = queues.map { |q| "queue:#{q}" }
cmd << TIMEOUT cmd << TIMEOUT
cmd cmd
end end