Module: GovukHealthcheck

Defined in:
lib/govuk_app_config/govuk_healthcheck.rb,
lib/govuk_app_config/govuk_healthcheck/redis.rb,
lib/govuk_app_config/govuk_healthcheck/checkup.rb,
lib/govuk_app_config/govuk_healthcheck/mongoid.rb,
lib/govuk_app_config/govuk_healthcheck/rails_cache.rb,
lib/govuk_app_config/govuk_healthcheck/active_record.rb,
lib/govuk_app_config/govuk_healthcheck/sidekiq_redis.rb

Defined Under Namespace

Classes: ActiveRecord, Checkup, Mongoid, RailsCache, Redis, SidekiqRedis

Constant Summary collapse

STATUSES =
[
  OK = :ok,
  WARNING = :warning,
  CRITICAL = :critical,
].freeze

Class Method Summary collapse

Class Method Details

.healthcheck(checks) ⇒ Object



21
22
23
# File 'lib/govuk_app_config/govuk_healthcheck.rb', line 21

def self.healthcheck(checks)
  Checkup.new(checks).run
end

.rack_response(*checks) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/govuk_app_config/govuk_healthcheck.rb', line 10

def self.rack_response(*checks)
  proc do
    checkup = healthcheck(checks)
    [
      checkup[:status] == :ok ? 200 : 500,
      { "Content-Type" => "application/json" },
      [JSON.dump(checkup)],
    ]
  end
end