AcquireFunc acquires a [Conn] and calls f with that [Conn]. ctx will only affect the [Pool.Acquire]. It has no effect on the call of f. The return value is either an error acquiring the [Conn] or the return value of f. The [Conn] is automatically released after the call of f.
(ctx context.Context, f func(*Conn) error)
| 669 | // call of f. The return value is either an error acquiring the [Conn] or the return value of f. The [Conn] is |
| 670 | // automatically released after the call of f. |
| 671 | func (p *Pool) AcquireFunc(ctx context.Context, f func(*Conn) error) error { |
| 672 | conn, err := p.Acquire(ctx) |
| 673 | if err != nil { |
| 674 | return err |
| 675 | } |
| 676 | defer conn.Release() |
| 677 | |
| 678 | return f(conn) |
| 679 | } |
| 680 | |
| 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. |