debian-mirror-gitlab/lib/gitlab/health_checks/redis/redis_abstract_check.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
851 B
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
module Gitlab
module HealthChecks
module Redis
module RedisAbstractCheck
include SimpleAbstractCheck
def check_up
successful?(check)
end
private
def redis_instance_class_name
Gitlab::Redis.const_get(redis_instance_name.camelize, false)
end
def metric_prefix
"redis_#{redis_instance_name}_ping"
end
def redis_instance_name
name.sub(/_check$/, '')
end
def successful?(result)
result == 'PONG'
end
# rubocop: disable CodeReuse/ActiveRecord
def check
catch_timeout 10.seconds do
redis_instance_class_name.with(&:ping)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
end