Sha256: 48b88d7b581622a58a1c532eaf5e7876adad5223ef4a6299e39f93dc4beb5cd6

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

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

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

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

      def self.produce(channel, event)
        new(channel).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

1 entries across 1 versions & 1 rubygems

Version Path
event_bus_rb-2.0.3 lib/event_bus/broker/rabbit/topic.rb