<commit_before># frozen_string_literal: true

module RubyRabbitmqJanus
  module Rabbit
    module Publisher
      # @author VAILLANT Jeremy <<EMAIL>>
      # This publisher send and read an message in admin queues
      class PublisherAdmin < Publisher
        # Intialize an queue non eclusive for admin/monitor API with Janus
        #
        # @param [String] exchange Exchange used for the transaction
        def initialize(exchange)
          @reply = exchange.queue(Tools::Config.instance.queue_admin_from)
          super(exchange)
          subscribe_to_queue
        rescue
          raise Errors::Rabbit::PublisherAdmin::Initialize
        end

        # Send an message to queue and waiting a response
        #
        # @param [String] request JSON request sending to rabbitmq queue
        #
        # @return [Janus::Response::Standard] response for an request reading
        #   by janus instance
        def publish(request)
          # super(request)
          @message = request
          concat = request.options.merge!(reply_to: reply.name)
          @exchange.publish(@message.to_json, concat)
          # p "Waiting response ...."
          # return_response
        rescue
          raise Errors::Rabbit::PublisherAdmin::Pusblish
        end

        private

        attr_reader :reply
      end
    end
  end
end<commit_msg>Use queue exclusive for admin response<commit_after># frozen_string_literal: true

module RubyRabbitmqJanus
  module Rabbit
    module Publisher
      # @author VAILLANT Jeremy <<EMAIL>>
      # This publisher send and read an message in admin queues
      class PublisherAdmin < Publisher
        # Intialize an queue non eclusive for admin/monitor API with Janus
        #
        # @param [String] exchange Exchange used for the transaction
        def initialize(exchange)
          @reply = exchange.queue('', exclusive: true)
          # @reply = exchange.queue(Tools::Config.instance.queue_admin_from)
          super(exchange)
          subscribe_to_queue
        rescue
          raise Errors::Rabbit::PublisherAdmin::Initialize
        end

        # Send an message to queue and waiting a response
        #
        # @param [String] request JSON request sending to rabbitmq queue
        #
        # @return [Janus::Response::Admin] response for an request reading
        #   by janus instance
        def publish(request)
          @message = request
          @exchange.publish(@message.to_json,
                            request.options.merge!(reply_to: reply.name))
          return_response
        rescue
          raise Errors::Rabbit::PublisherAdmin::Pusblish
        end

        private

        attr_reader :reply
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06691176470588235, 'fraction_numerical': 0.0, 'mean_word_length': 2.1713286713286712, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7545809', 'n_tokens_mistral': 711, 'n_tokens_neox': 679, 'n_words': 216}