Sha256: 8cf5585925d1246e2f62a44c82f713443f18ccf1cc7e514fd8a7ae0b114418bb

Contents?: true

Size: 775 Bytes

Versions: 43

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Rabbit
    module Publisher
      # Publisher to queue `janus-instance`
      class JanusInstance
        def initialize
          @rabbit = RubyRabbitmqJanus::Rabbit::Connect.new
        rescue
          raise Errors::Rabbit::Publisher::JanusInstance::Initialize
        end

        def publish(data)
          @rabbit.start
          channel = @rabbit.channel
          queue = channel.queue(Tools::Config.instance.queue_janus_instance)
          channel.default_exchange.publish(data.to_json,
                                           routing_key: queue.name)
          @rabbit.close
        rescue
          raise Errors::Rabbit::Publisher::JanusInstance::Publish
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.6.0.pre.228 lib/rrj/rabbit/publisher/janus_instance.rb
ruby_rabbitmq_janus-2.6.0.pre.227 lib/rrj/rabbit/publisher/janus_instance.rb
ruby_rabbitmq_janus-2.6.0.pre.226 lib/rrj/rabbit/publisher/janus_instance.rb