22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# 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 {
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
|