Sha256: fb2c503db5d77332ce75bf2037ec879ece8213d117e34389f638dd93a4a455fd

Contents?: true

Size: 563 Bytes

Versions: 3

Compression:

Stored size: 563 Bytes

Contents

require 'singleton'
module RailwayIpc
  class Publisher < Sneakers::Publisher
    include ::Singleton

    def self.exchange(exchange)
      @exchange_name = exchange
    end

    def self.exchange_name
      raise 'Subclass must set the exchange' unless @exchange_name
      @exchange_name
    end


    def initialize
      super(exchange: self.class.exchange_name, exchange_type: :fanout)
    end

    def publish(message)
      RailwayIpc.logger.info(message, "Publishing message")
      super(RailwayIpc::Rabbitmq::Payload.encode(message))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
railway-ipc-0.1.3 lib/railway_ipc/publisher.rb
railway-ipc-0.1.2 lib/railway_ipc/publisher.rb
railway-ipc-0.1.1 lib/railway_ipc/publisher.rb