lib/sidekiq-bus.rb in sidekiq-bus-0.6.3 vs lib/sidekiq-bus.rb in sidekiq-bus-0.7.0
- old
+ new
@@ -3,12 +3,10 @@
require 'queue-bus'
require 'sidekiq_bus/adapter'
require 'sidekiq_bus/version'
require 'sidekiq_bus/middleware/retry'
-QueueBus.adapter = QueueBus::Adapters::Sidekiq.new
-
module SidekiqBus
# This method will analyze the current queues and generate an array that
# can operate as the sidekiq queues configuration. It should be based on how
# The sidekiq CLI builds weighted queues.
#
@@ -41,6 +39,13 @@
# Creates an array of N length with the same queue name (N=weight) then
# flattened into a single array
entries.flat_map { |e| Array.new(e.weight, e.queue) }
end
+end
+
+if QueueBus.has_adapter?
+ warn '[SidekiqBus] Not setting adapter on queue-bus because ' \
+ "#{QueueBus.adapter.class.name} is already the adapter"
+else
+ QueueBus.adapter = QueueBus::Adapters::Sidekiq.new
end