Class: Totoro::Queue
- Inherits:
-
Object
- Object
- Totoro::Queue
- Defined in:
- lib/totoro/queue.rb
Class Method Summary collapse
- .channel ⇒ Object
- .connection ⇒ Object
-
.enqueue(id, payload) ⇒ Object
enqueue = publish to direct exchange.
- .exchange ⇒ Object
- .subscribe(id) ⇒ Object
Class Method Details
.channel ⇒ Object
8 9 10 |
# File 'lib/totoro/queue.rb', line 8 def channel @channel ||= connection.create_channel end |
.connection ⇒ Object
4 5 6 |
# File 'lib/totoro/queue.rb', line 4 def connection @connection ||= Bunny.new(Totoro::Config.connect).tap(&:start) end |
.enqueue(id, payload) ⇒ Object
enqueue = publish to direct exchange
17 18 19 20 21 |
# File 'lib/totoro/queue.rb', line 17 def enqueue(id, payload) queue = channel.queue(*Totoro::Config.queue(id)) payload = JSON.dump payload exchange.publish(payload, routing_key: queue.name) end |
.exchange ⇒ Object
12 13 14 |
# File 'lib/totoro/queue.rb', line 12 def exchange @exchanges ||= channel.default_exchange end |