MCPcopy
hub / github.com/redis/go-redis / ProcessOnGet

Method ProcessOnGet

internal/pool/hooks.go:73–91  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

71// ProcessOnGet calls all OnGet hooks in order.
72// If any hook returns an error, processing stops and the error is returned.
73func (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.

Callers 3

TestPoolHookManagerFunction · 0.95
TestHookErrorHandlingFunction · 0.95
getConnMethod · 0.80

Calls 1

OnGetMethod · 0.65

Tested by 2

TestPoolHookManagerFunction · 0.76
TestHookErrorHandlingFunction · 0.76