lib/cotton_tail/queue/bunny.rb in cotton-tail-0.2.1 vs lib/cotton_tail/queue/bunny.rb in cotton-tail-0.3.0

- old
+ new

@@ -8,19 +8,20 @@ # A wrapper around a ::Bunny::Queue that makes it interchangeable with a # standard Ruby Queue class Bunny < SimpleDelegator extend Forwardable - def self.call(name:, **opts) - new(name, **opts) + def self.call(**opts) + new(**opts) end - def initialize(name, manual_ack: false, **opts) + def initialize(name:, connection:, manual_ack: false, **opts) super ::Queue.new @name = name @source_opts = opts + @connection = connection watch_source manual_ack end def push(args) @@ -38,17 +39,13 @@ source.bind('amq.topic', routing_key: routing_key) end private - def_delegator :'CottonTail.configuration', :connection_args + attr_reader :connection def watch_source(manual_ack) source.subscribe(manual_ack: manual_ack) { |*args| self << args } - end - - def connection - @connection ||= ::Bunny.new(*connection_args).start end def source @source ||= channel.queue(@name, **@source_opts) end