mirror of https://github.com/go-redis/redis.git
Merge pull request #1891 from gozeloglu/rmv-empty-fnc
empty hooks.withContext removed
This commit is contained in:
commit
aac0ea4447
20
redis.go
20
redis.go
|
@ -51,9 +51,7 @@ func (hs hooks) process(
|
||||||
ctx context.Context, cmd Cmder, fn func(context.Context, Cmder) error,
|
ctx context.Context, cmd Cmder, fn func(context.Context, Cmder) error,
|
||||||
) error {
|
) error {
|
||||||
if len(hs.hooks) == 0 {
|
if len(hs.hooks) == 0 {
|
||||||
err := hs.withContext(ctx, func() error {
|
err := fn(ctx, cmd)
|
||||||
return fn(ctx, cmd)
|
|
||||||
})
|
|
||||||
cmd.SetErr(err)
|
cmd.SetErr(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -69,9 +67,7 @@ func (hs hooks) process(
|
||||||
}
|
}
|
||||||
|
|
||||||
if retErr == nil {
|
if retErr == nil {
|
||||||
retErr = hs.withContext(ctx, func() error {
|
retErr = fn(ctx, cmd)
|
||||||
return fn(ctx, cmd)
|
|
||||||
})
|
|
||||||
cmd.SetErr(retErr)
|
cmd.SetErr(retErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,9 +85,7 @@ func (hs hooks) processPipeline(
|
||||||
ctx context.Context, cmds []Cmder, fn func(context.Context, []Cmder) error,
|
ctx context.Context, cmds []Cmder, fn func(context.Context, []Cmder) error,
|
||||||
) error {
|
) error {
|
||||||
if len(hs.hooks) == 0 {
|
if len(hs.hooks) == 0 {
|
||||||
err := hs.withContext(ctx, func() error {
|
err := fn(ctx, cmds)
|
||||||
return fn(ctx, cmds)
|
|
||||||
})
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +100,7 @@ func (hs hooks) processPipeline(
|
||||||
}
|
}
|
||||||
|
|
||||||
if retErr == nil {
|
if retErr == nil {
|
||||||
retErr = hs.withContext(ctx, func() error {
|
retErr = fn(ctx, cmds)
|
||||||
return fn(ctx, cmds)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for hookIndex--; hookIndex >= 0; hookIndex-- {
|
for hookIndex--; hookIndex >= 0; hookIndex-- {
|
||||||
|
@ -128,10 +120,6 @@ func (hs hooks) processTxPipeline(
|
||||||
return hs.processPipeline(ctx, cmds, fn)
|
return hs.processPipeline(ctx, cmds, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs hooks) withContext(ctx context.Context, fn func() error) error {
|
|
||||||
return fn()
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
type baseClient struct {
|
type baseClient struct {
|
||||||
|
|
Loading…
Reference in New Issue