ProcessOnGet calls all OnGet hooks in order. If any hook returns an error, processing stops and the error is returned.
(ctx context.Context, conn *Conn, isNewConn bool)
| 71 | // ProcessOnGet calls all OnGet hooks in order. |
| 72 | // If any hook returns an error, processing stops and the error is returned. |
| 73 | func (phm *PoolHookManager) ProcessOnGet(ctx context.Context, conn *Conn, isNewConn bool) (acceptConn bool, err error) { |
| 74 | // Copy slice reference while holding lock (fast) |
| 75 | phm.hooksMu.RLock() |
| 76 | hooks := phm.hooks |
| 77 | phm.hooksMu.RUnlock() |
| 78 | |
| 79 | // Call hooks without holding lock (slow operations) |
| 80 | for _, hook := range hooks { |
| 81 | acceptConn, err := hook.OnGet(ctx, conn, isNewConn) |
| 82 | if err != nil { |
| 83 | return false, err |
| 84 | } |
| 85 | |
| 86 | if !acceptConn { |
| 87 | return false, nil |
| 88 | } |
| 89 | } |
| 90 | return true, nil |
| 91 | } |
| 92 | |
| 93 | // ProcessOnPut calls all OnPut hooks in order. |
| 94 | // The first hook that returns shouldRemove=true or shouldPool=false will stop processing. |