<commit_before># encoding: utf-8

require "amq/client/entity"
require "amq/client/adapter"
require "amq/client/mixins/anonymous_entity"

module AMQ
  module Client
    class Queue < Entity

      #
      # Behaviors
      #

      include AnonymousEntityMixin


      #
      # API
      #

      attr_reader :name

      def initialize(client, channel, name)
        super(client)

        @name    = name
        @channel = channel
      end


      def declare(passive = false, durable = false, exclusive = false, auto_delete = false, nowait = false, arguments = nil, &block)
        @client.send(Protocol::Queue::Declare.encode(@channel.id, @name, passive, durable, exclusive, auto_delete, nowait, arguments))

        self.callbacks[:declare] = block
        self.execute_callback(:declare) if nowait


        @channel.queues_awaiting_declare_ok << self

        if @client.sync?
          @client.read_until_receives(Protocol::Queue::DeclareOk) unless nowait
        end

        self
      end


      def delete(if_unused = false, if_empty = false, nowait = false, &block)
        @client.send(Protocol::Queue::Delete.encode(@channel.id, @name, if_unused, if_empty, nowait))

        self.callbacks[:delete] = block

        # TODO: delete itself from queues cache
        @channel.queues_awaiting_delete_ok.push(self)

        self
      end # delete(channel, queue, if_unused, if_empty, nowait, &block)



      def bind(exchange, routing_key = AMQ::Protocol::EMPTY_STRING, nowait = false, arguments = nil, &block)
        exchange_name = if exchange.respond_to?(:name)
                          exchange.name
                        else

                          exchange<commit_msg>"Immediate" callback execution when nowait is used is a very controversal idea, see 0c95c106f for reasoning<commit_after># encoding: utf-8

require "amq/client/entity"
require "amq/client/adapter"
require "amq/client/mixins/anonymous_entity"

module AMQ
  module Client
    class Queue < Entity

      #
      # Behaviors
      #

      include AnonymousEntityMixin


      #
      # API
      #

      attr_reader :name

      def initialize(client, channel, name)
        super(client)

        @name    = name
        @channel = channel
      end


      def declare(passive = false, durable = false, exclusive = false, auto_delete = false, nowait = false, arguments = nil, &block)
        @client.send(Protocol::Queue::Declare.encode(@channel.id, @name, passive, durable, exclusive, auto_delete, nowait, arguments))

        self.callbacks[:declare] = block
        @channel.queues_awaiting_declare_ok << self

        if @client.sync?
          @client.read_until_receives(Protocol::Queue::DeclareOk) unless nowait
        end

        self
      end


      def delete(if_unused = false, if_empty = false, nowait = false, &block)
        @client.send(Protocol::Queue::Delete.encode(@channel.id, @name, if_unused, if_empty, nowait))

        self.callbacks[:delete] = block

        # TODO: delete itself from queues cache
        @channel.queues_awaiting_delete_ok.push(self)

        self
      end # delete(channel, queue, if_unused, if_empty, nowait, &block)



      def bind(exchange, routing_key = AMQ::Protocol::EMPTY_STRING, nowait = false, arguments = nil, &block)
        exchange_name = if exchange.respond_to?(:name)
                          exchange.name
                        else

                          exchange
{'fraction_non_alphanumeric': 0.09633294528521537, 'fraction_numerical': 0.002328288707799767, 'mean_word_length': 2.4165009940357853, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '4711386', 'n_tokens_mistral': 1030, 'n_tokens_neox': 980, 'n_words': 239}