Class: ActiveRecord::Health::Adapters::PostgreSQLAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord/health/adapters/postgresql_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(_connection) ⇒ Object



7
8
9
# File 'lib/activerecord/health/adapters/postgresql_adapter.rb', line 7

def self.build(_connection)
  new
end

Instance Method Details

#active_session_count_queryObject



15
16
17
18
19
20
21
22
23
# File 'lib/activerecord/health/adapters/postgresql_adapter.rb', line 15

def active_session_count_query
  "    SELECT count(*)\n    FROM pg_stat_activity\n    WHERE state = 'active'\n      AND backend_type = 'client backend'\n      AND pid != pg_backend_pid()\n  SQL\nend\n".squish

#execute_with_timeout(connection, query, timeout) ⇒ Object



25
26
27
28
29
30
# File 'lib/activerecord/health/adapters/postgresql_adapter.rb', line 25

def execute_with_timeout(connection, query, timeout)
  connection.transaction do
    connection.execute("SET LOCAL statement_timeout = '#{timeout}s'")
    connection.select_value(query)
  end
end

#nameObject



11
12
13
# File 'lib/activerecord/health/adapters/postgresql_adapter.rb', line 11

def name
  :postgresql
end