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

Method ProcessOnPut

internal/pool/hooks.go:95–122  ·  view source on GitHub ↗

ProcessOnPut calls all OnPut hooks in order. The first hook that returns shouldRemove=true or shouldPool=false will stop processing.

(ctx context.Context, conn *Conn)

Source from the content-addressed store, hash-verified

93// ProcessOnPut calls all OnPut hooks in order.
94// The first hook that returns shouldRemove=true or shouldPool=false will stop processing.
95func (phm *PoolHookManager) ProcessOnPut(ctx context.Context, conn *Conn) (shouldPool bool, shouldRemove bool, err error) {
96 // Copy slice reference while holding lock (fast)
97 phm.hooksMu.RLock()
98 hooks := phm.hooks
99 phm.hooksMu.RUnlock()
100
101 shouldPool = true // Default to pooling the connection
102
103 // Call hooks without holding lock (slow operations)
104 for _, hook := range hooks {
105 hookShouldPool, hookShouldRemove, hookErr := hook.OnPut(ctx, conn)
106
107 if hookErr != nil {
108 return false, true, hookErr
109 }
110
111 // If any hook says to remove or not pool, respect that decision
112 if hookShouldRemove {
113 return false, true, nil
114 }
115
116 if !hookShouldPool {
117 shouldPool = false
118 }
119 }
120
121 return shouldPool, false, nil
122}
123
124// ProcessOnRemove calls all OnRemove hooks in order.
125func (phm *PoolHookManager) ProcessOnRemove(ctx context.Context, conn *Conn, reason error) {

Callers 3

TestPoolHookManagerFunction · 0.95
TestHookShouldRemoveFunction · 0.95
putConnMethod · 0.80

Calls 1

OnPutMethod · 0.65

Tested by 2

TestPoolHookManagerFunction · 0.76
TestHookShouldRemoveFunction · 0.76