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
|
|
|
|
|
|
|
|
def redis_instance_class_name
|
|
|
|
Gitlab::Redis.const_get(redis_instance_name.camelize, false)
|
|
|
|
end
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
private
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
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
|