Class: HealthMonitor::Providers::Database

Inherits:
Base
  • Object
show all
Defined in:
lib/health_monitor/providers/database.rb

Instance Attribute Summary

Attributes inherited from Base

#configuration, #request

Instance Method Summary collapse

Methods inherited from Base

#configure, #initialize

Constructor Details

This class inherits a constructor from HealthMonitor::Providers::Base

Instance Method Details

#check!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/health_monitor/providers/database.rb', line 10

def check!
  failed_databases = []

  ActiveRecord::Base.connection_handler.connection_pool_list(:all).each do |cp|
    cp.connection.execute('SELECT 1')
  rescue Exception
    failed_databases << cp.db_config.name
  end

  raise "unable to connect to: #{failed_databases.uniq.join(',')}" unless failed_databases.empty?
rescue Exception => e
  raise DatabaseException.new(e.message)
end