Module: ActiveRecord::DynamicTimeout::PostgresAdapterExtension

Defined in:
lib/active_record/dynamic_timeout/extensions/postgres_adapter_extension.rb

Instance Method Summary collapse

Instance Method Details

#reset_connection_timeout(raw_connection) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/active_record/dynamic_timeout/extensions/postgres_adapter_extension.rb', line 12

def reset_connection_timeout(raw_connection)
  timeout = default_statement_timeout
  if set_to_default_timeout?(timeout)
    raw_connection.query("SET SESSION statement_timeout TO DEFAULT")
  else
    raw_connection.query("SET SESSION statement_timeout TO #{quote(timeout)}")
  end
end

#set_connection_timeout(raw_connection, timeout_seconds) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/active_record/dynamic_timeout/extensions/postgres_adapter_extension.rb', line 3

def set_connection_timeout(raw_connection, timeout_seconds)
  if set_to_default_timeout?(timeout_seconds)
    raw_connection.query("SET SESSION statement_timeout TO DEFAULT")
  else
    timeout = (timeout_seconds * 1000).to_i
    raw_connection.query("SET SESSION statement_timeout TO #{quote(timeout)}")
  end
end

#supports_dynamic_timeouts?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/active_record/dynamic_timeout/extensions/postgres_adapter_extension.rb', line 25

def supports_dynamic_timeouts?
  true
end

#timeout_set_client_side?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/active_record/dynamic_timeout/extensions/postgres_adapter_extension.rb', line 21

def timeout_set_client_side?
  false
end