Class: EventPeople::Broker::Rabbit::Topic

Inherits:
Object
  • Object
show all
Defined in:
lib/event_people/broker/rabbit/topic.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ Topic

Returns a new instance of Topic.



4
5
6
# File 'lib/event_people/broker/rabbit/topic.rb', line 4

def initialize(channel)
  @channel = channel
end

Class Method Details

.produce(channel, event) ⇒ Object



16
17
18
# File 'lib/event_people/broker/rabbit/topic.rb', line 16

def self.produce(channel, event)
  new(channel).produce(event)
end

.topic(channel) ⇒ Object



8
9
10
# File 'lib/event_people/broker/rabbit/topic.rb', line 8

def self.topic(channel)
  new(channel).topic
end

Instance Method Details

#produce(event) ⇒ Object



20
21
22
23
# File 'lib/event_people/broker/rabbit/topic.rb', line 20

def produce(event)
  topic.publish(event.payload, routing_key: event.name,
                content_type: 'application/json')
end

#topicObject



12
13
14
# File 'lib/event_people/broker/rabbit/topic.rb', line 12

def topic
  @topic ||= channel.topic(EventPeople::Config::TOPIC, topic_options)
end