class MicroBunny::Subscriber
Attributes
callback[R]
channel[R]
exchange[R]
settings[R]
Public Class Methods
new(channel, exchange, callback)
click to toggle source
# File lib/microbunny/subscriber.rb, line 3 def initialize(channel, exchange, callback) @channel = channel @exchange = exchange @callback = callback @settings = settings end
Public Instance Methods
records(records)
click to toggle source
# File lib/microbunny/subscriber.rb, line 16 def records(records) records.each do |record| queue = find_queue_for_record(record) queue.bind(exchange, routing_key: record.routing_key_matcher) queue.subscribe { |_info, _meta, payload| callback.call(payload) } end end
topic(topic)
click to toggle source
# File lib/microbunny/subscriber.rb, line 10 def topic(topic) queue = find_queue(topic) queue.bind(exchange, routing_key: "*") queue.subscribe { |_info, _meta, payload| callback.call(payload) } end
Private Instance Methods
find_queue(name)
click to toggle source
# File lib/microbunny/subscriber.rb, line 28 def find_queue(name) channel.queue(name) end
find_queue_for_record(record)
click to toggle source
# File lib/microbunny/subscriber.rb, line 32 def find_queue_for_record(record) find_queue(record.address) end