<commit_before># Copyright (c) 2012 National ICT Australia Limited (NICTA).
# This software may be used and distributed solely under the terms of the MIT license (License).
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
# By downloading or using this software you accept the terms and the liability disclaimer in the License.

require 'amqp'
require 'omf_common/comm/amqp/amqp_topic'
#require 'omf_common/comm/monkey_patches'

module OmfCommon
  class Comm
    class AMQP
      class Communicator < OmfCommon::Comm

        # def initialize(opts = {})
          # # ignore arguments
        # end

        attr_reader :channel

        # Initialize comms layer
        #
        def init(opts = {})
          @opts = {
            #:ssl (Hash) TLS (SSL) parameters to use.
            heartbeat: 20, # (Fixnum) - default: 0 Connection heartbeat, in seconds. 0 means no heartbeat. Can also be configured server-side starting with RabbitMQ 3.0.
            #:on_tcp_connection_failure (#call) - A callable object that will be run if connection to server fails
            #:on_possible_authentication_failure (#call) - A callable object that will be run if authentication fails (see Authentication failure section)
            reconnect_delay: 20 # (Fixnum) - Delay in seconds before attempting reconnect on detected failure
          }.merge(opts)

          unless (@url = @opts.delete(:url))
            raise "Missing 'url' option for AQMP layer"
          end
          @address_prefix = @url + '/'
          _connect()
          super
        end

        def conn_info
          { proto: :amqp, user: ::AMQP.settings[:user], domain: ::AMQP.settings[:host] }
        end

        def string_to_topic_address(a_string)
          @address_prefix+a_string 
        end

        # Shut down comms layer
        def disconnect(opts = {})
          info "Disconnecting..."
        end

        # TODO: Should be thread safe and check if already connected
        def on_connected(&block)
          @on_connected_procs << block
        end

        # register callbacks to be called when the underlying AMQP layer
        # needs to reconnect to the AMQP server. This may require some additional<commit_msg>Prefix all AMQP topic names with "frcp." - Fixes #1557<commit_after># Copyright (c) 2012 National ICT Australia Limited (NICTA).
# This software may be used and distributed solely under the terms of the MIT license (License).
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
# By downloading or using this software you accept the terms and the liability disclaimer in the License.

require 'amqp'
require 'omf_common/comm/amqp/amqp_topic'
#require 'omf_common/comm/monkey_patches'

module OmfCommon
  class Comm
    class AMQP
      class Communicator < OmfCommon::Comm

        # def initialize(opts = {})
          # # ignore arguments
        # end

        attr_reader :channel

        # Initialize comms layer
        #
        def init(opts = {})
          @opts = {
            #:ssl (Hash) TLS (SSL) parameters to use.
            heartbeat: 20, # (Fixnum) - default: 0 Connection heartbeat, in seconds. 0 means no heartbeat. Can also be configured server-side starting with RabbitMQ 3.0.
            #:on_tcp_connection_failure (#call) - A callable object that will be run if connection to server fails
            #:on_possible_authentication_failure (#call) - A callable object that will be run if authentication fails (see Authentication failure section)
            reconnect_delay: 20 # (Fixnum) - Delay in seconds before attempting reconnect on detected failure
          }.merge(opts)

          unless (@url = @opts.delete(:url))
            raise "Missing 'url' option for AQMP layer"
          end
          @address_prefix = @url + '/frcp.'
          _connect()
          super
        end

        def conn_info
          { proto: :amqp, user: ::AMQP.settings[:user], domain: ::AMQP.settings[:host] }
        end

        def string_to_topic_address(a_string)
          @address_prefix+a_string
        end

        # Shut down comms layer
        def disconnect(opts = {})
          info "Disconnecting..."
        end

        # TODO: Should be thread safe and check if already connected
        def on_connected(&block)
          @on_connected_procs << block
        end

        # register callbacks to be called when the underlying AMQP layer
        # needs to reconnect to the AMQP server. This may require some additional
{'fraction_non_alphanumeric': 0.07599385020865364, 'fraction_numerical': 0.006149791346365034, 'mean_word_length': 2.388392857142857, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1459015', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1178, 'n_words': 468}