lib/sneakers/workergroup.rb in sneakers-2.6.0 vs lib/sneakers/workergroup.rb in sneakers-2.7.0

- old
+ new

@@ -27,17 +27,17 @@ if worker_classes.respond_to? :call worker_classes = worker_classes.call end - # if we don't provide a connection to a worker, + # If we don't provide a connection to a worker, # the queue used in the worker will create a new one - # so if we want to have a shared bunny connection for the workers - # we must create it here - bunny_connection = create_connection_or_nil - @workers = worker_classes.map{|w| w.new(nil, pool, {connection: bunny_connection}) } + @workers = worker_classes.map do |worker_class| + worker_class.new(nil, pool, { connection: config[:connection] }) + end + # if more than one worker this should be per worker # accumulate clients and consumers as well @workers.each do |worker| worker.run end @@ -45,26 +45,16 @@ # until @stop_flag.wait_for_set(Sneakers::CONFIG[:amqp_heartbeat]) Sneakers.logger.debug("Heartbeat: running threads [#{Thread.list.count}]") # report aggregated stats? end - end def stop Sneakers.logger.info("Shutting down workers") @workers.each do |worker| worker.stop end @stop_flag.set! end - - def create_bunny_connection - Bunny.new(Sneakers::CONFIG[:amqp], :vhost => Sneakers::CONFIG[:vhost], :heartbeat => Sneakers::CONFIG[:heartbeat], :logger => Sneakers::logger) - end - - def create_connection_or_nil - config[:share_bunny_connection] ? create_bunny_connection : nil - end - private :create_bunny_connection, :create_connection_or_nil end end