Class: EventBus::Broker::Rabbit::Topic
- Inherits:
-
Object
- Object
- EventBus::Broker::Rabbit::Topic
- Defined in:
- lib/event_bus/broker/rabbit/topic.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(connection) ⇒ Topic
constructor
A new instance of Topic.
- #produce(event) ⇒ Object
- #topic ⇒ Object
Constructor Details
#initialize(connection) ⇒ Topic
Returns a new instance of Topic.
4 5 6 |
# File 'lib/event_bus/broker/rabbit/topic.rb', line 4 def initialize(connection) @channel = connection end |
Class Method Details
.produce(connection, event) ⇒ Object
16 17 18 |
# File 'lib/event_bus/broker/rabbit/topic.rb', line 16 def self.produce(connection, event) new(connection).produce(event) end |
.topic(connection) ⇒ Object
8 9 10 |
# File 'lib/event_bus/broker/rabbit/topic.rb', line 8 def self.topic(connection) new(connection).topic end |
Instance Method Details
#produce(event) ⇒ Object
20 21 22 23 |
# 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 ⇒ Object
12 13 14 |
# File 'lib/event_bus/broker/rabbit/topic.rb', line 12 def topic @topic ||= channel.topic(EventBus::Config::TOPIC, ) end |