MCPcopy
hub / github.com/jackc/pgx / AcquireAllIdle

Method AcquireAllIdle

pgxpool/pool.go:683–699  ·  view source on GitHub ↗

AcquireAllIdle atomically acquires all currently idle connections. Its intended use is for health check and keep-alive functionality. It does not update pool statistics.

(ctx context.Context)

Source from the content-addressed store, hash-verified

681// AcquireAllIdle atomically acquires all currently idle connections. Its intended use is for health check and
682// keep-alive functionality. It does not update pool statistics.
683func (p *Pool) AcquireAllIdle(ctx context.Context) []*Conn {
684 resources := p.p.AcquireAllIdle()
685 conns := make([]*Conn, 0, len(resources))
686 for _, res := range resources {
687 cr := res.Value()
688 if p.prepareConn != nil {
689 ok, err := p.prepareConn(ctx, cr.conn)
690 if !ok || err != nil {
691 res.Destroy()
692 continue
693 }
694 }
695 conns = append(conns, cr.getConn(p, res))
696 }
697
698 return conns
699}
700
701// Reset closes all connections, but leaves the pool open. It is intended for use when an error is detected that would
702// disrupt all connections (such as a network interruption or a server state change).

Callers 4

checkConnsHealthMethod · 0.80
TestPoolBeforeAcquireFunction · 0.80
TestPoolPrepareConnFunction · 0.80
TestPoolAcquireAllIdleFunction · 0.80

Calls 2

getConnMethod · 0.80
ValueMethod · 0.45

Tested by 3

TestPoolBeforeAcquireFunction · 0.64
TestPoolPrepareConnFunction · 0.64
TestPoolAcquireAllIdleFunction · 0.64