<commit_before># encoding: utf-8

require "eventmachine"
require "amq/client"
require "amq/client/framing/string/frame"

module AMQ
  module Client
    class EventMachineClient < EM::Connection

      #
      # Behaviors
      #

      include AMQ::Client::Adapter


      #
      # API
      #

      def self.connect(settings = {}, &block)
        @settings = Settings.configure(settings)

        instance = EventMachine.connect(@settings[:host], @settings[:port], self, @settings)
        instance.register_connection_callback(&block)

        instance
      end

      # Reconnect after a period of wait.
      #
      # @param [Fixnum]  period Period of time, in seconds, to wait before reconnection attempt.
      # @param [Boolean] force  If true, enforces immediate reconnection.
      # @api public
      def reconnect(force = false, period = 5)
        if @reconnecting and not force
          EventMachine::Timer.new(period) {
            reconnect(true, period)
          }
          return
        end

        if !@reconnecting
          @reconnecting = true
          @connections.each { |c| c.handle_connection_interruption }
          self.reset
        end

        EventMachine.reconnect(@settings[:host], @settings[:port], self)
      end





      # Defines a callback that will be executed when AMQP connection is considered open:
      # client and broker has agreed on max channel identifier and maximum allowed frame
      # size and authentication succeeds. You can define more than one callback.
      #<commit_msg>Fix reconnection method<commit_after># encoding: utf-8

require "eventmachine"
require "amq/client"
require "amq/client/framing/string/frame"

module AMQ
  module Client
    class EventMachineClient < EM::Connection

      #
      # Behaviors
      #

      include AMQ::Client::Adapter


      #
      # API
      #

      def self.connect(settings = {}, &block)
        @settings = Settings.configure(settings)

        instance = EventMachine.connect(@settings[:host], @settings[:port], self, @settings)
        instance.register_connection_callback(&block)

        instance
      end

      # Reconnect after a period of wait.
      #
      # @param [Fixnum]  period Period of time, in seconds, to wait before reconnection attempt.
      # @param [Boolean] force  If true, enforces immediate reconnection.
      # @api public
      def reconnect(force = false, period = 5)
        if @reconnecting and not force
          EventMachine::Timer.new(period) {
            reconnect(true, period)
          }
          return
        end

        if !@reconnecting
          @reconnecting = true

          self.handle_connection_interruption
          self.reset
        end

        EventMachine.reconnect(@settings[:host], @settings[:port], self)
      end





      # Defines a callback that will be executed when AMQP connection is considered open:
      # client and broker has agreed on max channel identifier and maximum allowed frame
      # size and authentication succeeds. You can define more than one callback.
      #
{'fraction_non_alphanumeric': 0.08192457737321196, 'fraction_numerical': 0.0013003901170351106, 'mean_word_length': 2.333694474539545, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4215808', 'n_tokens_mistral': 827, 'n_tokens_neox': 788, 'n_words': 254}