Skip to content

Commit

Permalink
Merge pull request redis#1477 from go-redis/fix/hooks-lifo
Browse files Browse the repository at this point in the history
Change hooks to be LIFO
  • Loading branch information
vmihailenco authored Sep 10, 2020
2 parents b1866ca + 5aaa6c6 commit fb80d42
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func (hs hooks) beforeProcess(ctx context.Context, cmd Cmder) (context.Context,

func (hs hooks) afterProcess(ctx context.Context, cmd Cmder) error {
var firstErr error
for _, h := range hs.hooks {
err := h.AfterProcess(ctx, cmd)
if err != nil && firstErr == nil {
for i := len(hs.hooks) - 1; i >= 0; i-- {
h := hs.hooks[i]
if err := h.AfterProcess(ctx, cmd); err != nil && firstErr == nil {
firstErr = err
}
}
Expand Down Expand Up @@ -118,9 +118,9 @@ func (hs hooks) beforeProcessPipeline(ctx context.Context, cmds []Cmder) (contex

func (hs hooks) afterProcessPipeline(ctx context.Context, cmds []Cmder) error {
var firstErr error
for _, h := range hs.hooks {
err := h.AfterProcessPipeline(ctx, cmds)
if err != nil && firstErr == nil {
for i := len(hs.hooks) - 1; i >= 0; i-- {
h := hs.hooks[i]
if err := h.AfterProcessPipeline(ctx, cmds); err != nil && firstErr == nil {
firstErr = err
}
}
Expand Down

0 comments on commit fb80d42

Please sign in to comment.