module PgFailover::SequelAdapter::ConnectionValidator
Public Instance Methods
acquire(*adapter)
click to toggle source
Calls superclass method
# File lib/pg_failover/sequel_adapter.rb, line 22 def acquire(*adapter) connection = super PgFailover.connection_validator.call( throttle_by: connection, in_recovery: proc { result = connection.execute('select pg_is_in_recovery()', &:to_a).first %w[1 t true].include?(result['pg_is_in_recovery'].to_s) }, reconnect: proc { # This disconnect is copy pasted from the # https://github.com/jeremyevans/sequel/blob/5.15.0/lib/sequel/extensions/connection_validator.rb#L103-L109 # if pool_type == :sharded_threaded sync { allocated(adapter.last).delete(Thread.current) } else sync { @allocated.delete(Thread.current) } end disconnect_connection(connection) connection = super } ) connection end