class HealthInspector::Services::Postgres
Attributes
configuration[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
HealthInspector::Services::Base::new
# File lib/health_inspector/services/postgres.rb, line 11 def initialize super end
slug()
click to toggle source
# File lib/health_inspector/services/postgres.rb, line 15 def self.slug 'postgres' end
Public Instance Methods
inspect!()
click to toggle source
# File lib/health_inspector/services/postgres.rb, line 19 def inspect! connection = PG.connect(host: configuration['hostname'], port: configuration['port'] || 5432, dbname: configuration['database'], user: configuration['username'], password: configuration['password']) return { status: 'OK', timestamp: Time.now.utc.to_i } if connection rescue StandardError => e { status: 'FAILED', message: "Could not connect to postgres. Error: #{e.inspect}", timestamp: Time.now.utc.to_i } ensure connection.close if connection end