Class: HealthCheck::RedisHealthCheck

Inherits:
Object
  • Object
show all
Extended by:
BaseHealthCheck
Defined in:
lib/health_check/redis_health_check.rb

Class Method Summary collapse

Methods included from BaseHealthCheck

create_error

Class Method Details

.checkObject



8
9
10
11
12
13
14
15
16
# File 'lib/health_check/redis_health_check.rb', line 8

def check
  raise "Wrong configuration. Missing 'redis' gem" unless defined?(::Redis)

  client.ping == 'PONG' ? '' : "Redis.ping returned #{res.inspect} instead of PONG"
rescue Exception => err
  create_error 'redis', err.message
ensure
  client.close if client.connected?
end

.clientObject



18
19
20
21
22
23
24
25
# File 'lib/health_check/redis_health_check.rb', line 18

def client
  @client ||= Redis.new(
    {
      url: HealthCheck.redis_url,
      password: HealthCheck.redis_password
    }.reject { |k, v| v.nil? }
  )
end