module Semian::PG
def async_connect_or_reset(*args)
def async_connect_or_reset(*args) acquire_semian_resource(adapter: :pg, scope: :connection) do super end end
def conninfo_hash
def conninfo_hash h = super h.merge!(connect_timeout: @connect_timeout) if @connect_timeout h end
def disabled?
def disabled? raw_semian_options.nil? end
def query_whitelisted?(sql)
def query_whitelisted?(sql) QUERY_WHITELIST =~ sql rescue ArgumentError return false unless sql.valid_encoding? raise end
def raw_semian_options
def raw_semian_options @raw_semian_options ||= begin @raw_semian_options = Semian::PG.retrieve_semian_configuration(@iopts[:host], @iopts[:port]) @raw_semian_options = @raw_semian_options.dup unless @raw_semian_options.nil? end end
def resource_exceptions
def resource_exceptions [::PG::ConnectionBad, ::PG::QueryCanceled].freeze end
def retrieve_semian_configuration(host, port)
def retrieve_semian_configuration(host, port) @semian_configuration.call(host, port) if @semian_configuration.respond_to?(:call) end
def semian_configuration=(configuration)
def semian_configuration=(configuration) raise ConfigurationChangedError unless @semian_configuration.nil? @semian_configuration = configuration end
def semian_identifier
def semian_identifier @semian_identifier ||= "pg_#{raw_semian_options[:name]}" if raw_semian_options && raw_semian_options[:name] @semian_identifier ||= "pg_#{@iopts[:host]}:#{@iopts[:port]}" end
def with_resource_timeout(temp_timeout)
def with_resource_timeout(temp_timeout) prev_conn_timeout = conninfo_hash[:connect_timeout] begin @connect_timeout = temp_timeout yield ensure @connect_timeout = prev_conn_timeout end end