Sha256: 1e63f5c5ccfa898b10b8b0e3a7e95f5bf600d7777834fed7c9a432de3261db82
Contents?: true
Size: 956 Bytes
Versions: 2
Compression:
Stored size: 956 Bytes
Contents
module PgHero module Methods module Replication def replica? unless defined?(@replica) @replica = select_one("SELECT pg_is_in_recovery()") end @replica end # http://www.postgresql.org/message-id/CADKbJJWz9M0swPT3oqe8f9+tfD4-F54uE6Xtkh4nERpVsQnjnw@mail.gmail.com def replication_lag select_one <<-SQL SELECT CASE WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM NOW() - pg_last_xact_replay_timestamp()) END AS replication_lag SQL end def replication_slots select_all <<-SQL SELECT slot_name, database, active FROM pg_replication_slots SQL end def replicating? select_all("SELECT state FROM pg_stat_replication").any? end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pghero-2.0.1 | lib/pghero/methods/replication.rb |
pghero-2.0.0 | lib/pghero/methods/replication.rb |