-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Calling AddHook() on a ClusterClient will not call hooks when using Watch(), or anything inside the Watch block.
Expected Behavior
I see watch ... unwatch in my logger.
Current Behavior
It prints nothing.
Possible Solution
Not a solution, but a workaround:
client := redis.NewClusterClient(&redis.ClusterOptions{
NewClient: func(opt *redis.Options) *redis.Client {
c := redis.NewClient(opt)
c.AddHook(myHooks{})
return c
},
})Steps to Reproduce
type myHooks struct{}
func (myHooks) DialHook(redis.DialHook) redis.DialHook { return nil }
func (myHooks) ProcessPipelineHook(redis.ProcessPipelineHook) redis.ProcessPipelineHook { return nil }
func (myHooks) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return func(ctx context.Context, cmd redis.Cmder) error {
defer fmt.Printf("%v\n", cmd)
return next(ctx, cmd)
}
}
client := redis.NewClusterClient(&redis.ClusterOptions{})
client.AddHook(myHooks{})
client.Watch(ctx, func(*redis.Tx) error { return nil }, "key") // should print 'watch key... unwatch'Context (Environment)
I'm trying to log my commands and everything inside Watch() is missing.
Detailed Description
Pass hooks to child clients.
Possible Implementation
Metadata
Metadata
Assignees
Labels
No labels