Class: CottonTail::Queue::Bunny
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- CottonTail::Queue::Bunny
- Extended by:
- Forwardable
- Defined in:
- lib/cotton_tail/queue/bunny.rb
Overview
A wrapper around a ::Bunny::Queue that makes it interchangeable with a standard Ruby Queue
Class Method Summary collapse
Instance Method Summary collapse
- #bind(routing_key) ⇒ Object
-
#initialize(name:, connection:, manual_ack: false, **opts) ⇒ Bunny
constructor
A new instance of Bunny.
- #pop ⇒ Object
- #push(request) ⇒ Object
Constructor Details
#initialize(name:, connection:, manual_ack: false, **opts) ⇒ Bunny
17 18 19 20 21 22 23 24 25 |
# File 'lib/cotton_tail/queue/bunny.rb', line 17 def initialize(name:, connection:, manual_ack: false, **opts) super ::Queue.new @name = name @source_opts = opts @connection = connection watch_source manual_ack end |
Class Method Details
.call(**opts) ⇒ Object
13 14 15 |
# File 'lib/cotton_tail/queue/bunny.rb', line 13 def self.call(**opts) new(**opts) end |
Instance Method Details
#bind(routing_key) ⇒ Object
36 37 38 |
# File 'lib/cotton_tail/queue/bunny.rb', line 36 def bind(routing_key) source.bind('amq.topic', routing_key: routing_key) end |
#pop ⇒ Object
32 33 34 |
# File 'lib/cotton_tail/queue/bunny.rb', line 32 def pop Request.new(*super) end |
#push(request) ⇒ Object
27 28 29 30 |
# File 'lib/cotton_tail/queue/bunny.rb', line 27 def push(request) bind request.routing_key exchange.publish request.payload, routing_key: request.routing_key end |