ebf98f27c4
Enables frozen string for the following: * lib/gitlab/fogbugz_import/**/*.rb * lib/gitlab/gfm/**/*.rb * lib/gitlab/git/**/*.rb * lib/gitlab/gitaly_client/**/*.rb * lib/gitlab/gitlab_import/**/*.rb * lib/gitlab/google_code_import/**/*.rb * lib/gitlab/gpg/**/*.rb * lib/gitlab/grape_logging/**/*.rb * lib/gitlab/graphql/**/*.rb * lib/gitlab/graphs/**/*.rb * lib/gitlab/hashed_storage/**/*.rb * lib/gitlab/health_checks/**/*.rb Partially address gitlab-org/gitlab-ce#47424.
47 lines
833 B
Ruby
47 lines
833 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module HealthChecks
|
|
module BaseAbstractCheck
|
|
def name
|
|
super.demodulize.underscore
|
|
end
|
|
|
|
def human_name
|
|
name.sub(/_check$/, '').capitalize
|
|
end
|
|
|
|
def readiness
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def liveness
|
|
HealthChecks::Result.new(true)
|
|
end
|
|
|
|
def metrics
|
|
[]
|
|
end
|
|
|
|
protected
|
|
|
|
def metric(name, value, **labels)
|
|
Metric.new(name, value, labels)
|
|
end
|
|
|
|
def with_timing
|
|
start = Time.now
|
|
result = yield
|
|
[result, Time.now.to_f - start.to_f]
|
|
end
|
|
|
|
def catch_timeout(seconds, &block)
|
|
begin
|
|
Timeout.timeout(seconds.to_i, &block)
|
|
rescue Timeout::Error => ex
|
|
ex
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|