class HealthMonitor::Providers::Database
Public Instance Methods
Source
# File lib/health_monitor/providers/database.rb, line 26 def check! checked = false failed_databases = [] ActiveRecord::Base.connection_handler.connection_pool_list(:all).each do |cp| next unless check_connection_pool?(cp) checked = true check_connection(cp) rescue Exception failed_databases << cp.db_config.name end raise "unable to connect to: #{failed_databases.uniq.join(',')}" unless failed_databases.empty? raise "no connections checked with name: #{configuration.config_name}" if configuration.config_name && !checked rescue Exception => e raise DatabaseException.new(e.message) end
Private Instance Methods
Source
# File lib/health_monitor/providers/database.rb, line 55 def check_connection(connection_pool) if connection_pool.respond_to?(:lease_connection) connection_pool.lease_connection.execute('SELECT 1') else connection_pool.connection.execute('SELECT 1') end end
Source
# File lib/health_monitor/providers/database.rb, line 51 def check_connection_pool?(connection_pool) configuration.config_name.nil? || configuration.config_name == connection_pool.db_config.name end
Source
# File lib/health_monitor/providers/database.rb, line 47 def configuration_class ::HealthMonitor::Providers::Database::Configuration end