Sha256: 07281e4268382324972241971dbfe7d9ceff4582e356094b45b18c4c48441cd1

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

module Orchestration
  module Services
    module RabbitMQ
      class Healthcheck
        include HealthcheckBase

        def initialize(env)
          @configuration = Configuration.new(env)
        end

        def connection_errors
          [
            Bunny::TCPConnectionFailedForAllHosts,
            AMQ::Protocol::EmptyResponseError
          ]
        end

        def connect
          host = @configuration.settings.fetch('host')
          port = @configuration.settings.fetch('port')

          connection = Bunny.new("amqp://#{host}:#{port}", log_file: devnull)
          connection.start
          connection.stop
        end

        private

        def devnull
          File.open(File::NULL, 'w')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orchestration-0.2.2 lib/orchestration/services/rabbitmq/healthcheck.rb
orchestration-0.2.1 lib/orchestration/services/rabbitmq/healthcheck.rb
orchestration-0.2.0 lib/orchestration/services/rabbitmq/healthcheck.rb