Sha256: 40a16c8543a897b0b4daf19c60101ff1b02e82e75121b0286c212c8c02e9ddc8

Contents?: true

Size: 688 Bytes

Versions: 2

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

require 'hey_doctor/version'
require 'hey_doctor/engine'

module HeyDoctor::Rack
  class HealthCheck
    def call(_env)
      [200, {}, [status]]
    end

    private

    def status
      response = {
        app: ::HeyDoctor::CheckApplicationHealthService.call,
        database: ::HeyDoctor::CheckDatabaseHealthService.call
      }

      unless ENV['REDIS_URL'].blank?
        response.merge!({ redis: ::HeyDoctor::CheckRedisHealthService.call })
      end

      unless ENV['SIDEKIQ_HOSTS'].blank?
        response.merge!(
          { sidekiq: ::HeyDoctor::CheckSidekiqHealthService.call }
        )
      end

      response.to_json
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hey_doctor-1.3.1 lib/hey_doctor.rb
hey_doctor-1.2.1 lib/hey_doctor.rb