Sha256: 345d5c8676824bb03065ec2279e6d84d24e015efd1f1e8d5ff253dfcf819be87

Contents?: true

Size: 691 Bytes

Versions: 4

Compression:

Stored size: 691 Bytes

Contents

module EventBus
  module Broker
    class Rabbit::Topic
      def initialize(connection)
        @channel = connection
      end

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

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

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

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

      private

      attr_reader :channel

      def topic_options
        { durable: true, auto_delete: false }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
event_bus_rb-2.0.2 lib/event_bus/broker/rabbit/topic.rb
event_bus_rb-2.0.1 lib/event_bus/broker/rabbit/topic.rb
event_bus_rb-2.0.0 lib/event_bus/broker/rabbit/topic.rb
event_bus_rb-1.1.0 lib/event_bus/broker/rabbit/topic.rb