class EventBus::Broker::Rabbit::Topic

Attributes

channel[R]

Public Class Methods

new(channel) click to toggle source
# File lib/event_bus/broker/rabbit/topic.rb, line 4
def initialize(channel)
  @channel = channel
end
produce(channel, event) click to toggle source
# File lib/event_bus/broker/rabbit/topic.rb, line 16
def self.produce(channel, event)
  new(channel).produce(event)
end
topic(channel) click to toggle source
# File lib/event_bus/broker/rabbit/topic.rb, line 8
def self.topic(channel)
  new(channel).topic
end

Public Instance Methods

produce(event) click to toggle source
# File lib/event_bus/broker/rabbit/topic.rb, line 20
def produce(event)
  topic.publish(event.payload, routing_key: event.name,
                content_type: 'application/json')
end
topic() click to toggle source
# File lib/event_bus/broker/rabbit/topic.rb, line 12
def topic
  @topic ||= channel.topic(EventBus::Config::TOPIC, topic_options)
end

Private Instance Methods

topic_options() click to toggle source
# File lib/event_bus/broker/rabbit/topic.rb, line 29
def topic_options
  { passive: true }
end