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)
| 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. |
| 683 | func (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). |