Sha256: a013df1e10316adbabba9636cb657fb032aeff321672920dbd5f0fd4fa5f2b60

Contents?: true

Size: 793 Bytes

Versions: 9

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module Orchestration
  module Services
    module Application
      class Healthcheck
        include HealthcheckBase

        def connect
          response = Net::HTTP.get_response(
            URI("http://localhost:#{@configuration.local_port}")
          )
          connection_error(response.code) if connection_error?(response.code)
        end

        def connection_errors
          [Errno::ECONNREFUSED, ApplicationConnectionError]
        end

        private

        def connection_error(code)
          raise ApplicationConnectionError,
                I18n.t('orchestration.application.connection_error', code: code)
        end

        def connection_error?(code)
          %w[502 503 500].include?(code)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
orchestration-0.3.3 lib/orchestration/services/application/healthcheck.rb
orchestration-0.3.2 lib/orchestration/services/application/healthcheck.rb
orchestration-0.3.1 lib/orchestration/services/application/healthcheck.rb
orchestration-0.3.0 lib/orchestration/services/application/healthcheck.rb
orchestration-0.2.8 lib/orchestration/services/application/healthcheck.rb
orchestration-0.2.7 lib/orchestration/services/application/healthcheck.rb
orchestration-0.2.6 lib/orchestration/services/application/healthcheck.rb
orchestration-0.2.5 lib/orchestration/services/application/healthcheck.rb
orchestration-0.2.4 lib/orchestration/services/application/healthcheck.rb