class Philae::PostgreSQLProbe
Attributes
name[R]
Public Class Methods
new(name, connection_string)
click to toggle source
# File lib/philae/pgsql_probe.rb, line 10 def initialize(name, connection_string) @name = name @connection_string = connection_string end
Public Instance Methods
check()
click to toggle source
# File lib/philae/pgsql_probe.rb, line 15 def check begin res = PG::Connection.ping(@connection_string) rescue return { healthy: false, comment: 'Unable to contact PostgreSQL' } end return { healthy: true, comment: '' } if res == PG::PQPING_OK # https://deveiate.org/code/pg/PG/Connection.html#method-c-ping reasons = { PG::PQPING_REJECT => 'server is alive but rejecting connections', PG::PQPING_NO_RESPONSE => 'could not establish connection', PG::PQPING_NO_ATTEMPT => 'connection not attempted (bad params)', } return { healthy: false, comment: "Ping to PostgreSQL failed with the following reason: #{reasons[res]}" } end