Skip to content

Commit 0ed4a44

Browse files
committed
fix: fix the withHook func
Signed-off-by: monkey <golang@88.com>
1 parent 4f38f23 commit 0ed4a44

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

redis.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func (hs *hooks) setDefaultHook(d defaultHook) {
158158
}
159159

160160
func (hs *hooks) withProcessHook(ctx context.Context, cmd Cmder, hook ProcessHook) error {
161-
for _, h := range hs.slice {
162-
if wrapped := h.ProcessHook(hook); wrapped != nil {
161+
for i := len(hs.slice) - 1; i >= 0; i-- {
162+
if wrapped := hs.slice[i].ProcessHook(hook); wrapped != nil {
163163
hook = wrapped
164164
}
165165
}
@@ -169,8 +169,8 @@ func (hs *hooks) withProcessHook(ctx context.Context, cmd Cmder, hook ProcessHoo
169169
func (hs *hooks) withProcessPipelineHook(
170170
ctx context.Context, cmds []Cmder, hook ProcessPipelineHook,
171171
) error {
172-
for _, h := range hs.slice {
173-
if wrapped := h.ProcessPipelineHook(hook); wrapped != nil {
172+
for i := len(hs.slice) - 1; i >= 0; i-- {
173+
if wrapped := hs.slice[i].ProcessPipelineHook(hook); wrapped != nil {
174174
hook = wrapped
175175
}
176176
}

0 commit comments

Comments
 (0)