Sha256: 7a799aecacb13a6d5b690c8ecf97e643cafc27d7b4982206dd746303d4de5c9f
Contents?: true
Size: 774 Bytes
Versions: 4
Compression:
Stored size: 774 Bytes
Contents
module Totoro class Queue class <<self def connection @connection ||= Bunny.new(Totoro::Config.connect).tap(&:start) end def channel @channel ||= connection.create_channel end def exchange @exchanges ||= channel.default_exchange end # enqueue = publish to direct exchange def enqueue(id, payload) queue = channel.queue(*Totoro::Config.queue(id)) payload = JSON.dump payload exchange.publish(payload, routing_key: queue.name) end def subscribe(id) queue = channel.queue(*Totoro::Config.queue(id)) queue.subscribe do |delivery_info, metadata, payload| yield(delivery_info, metadata, payload) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
totoro-0.1.3 | lib/totoro/queue.rb |
totoro-0.1.2 | lib/totoro/queue.rb |
totoro-0.1.1 | lib/totoro/queue.rb |
totoro-0.1.0 | lib/totoro/queue.rb |