mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
feat/redis_hook (#4233)
This commit is contained in:
parent
c9cbd74bf3
commit
fed835bc25
@ -90,6 +90,18 @@ type (
|
|||||||
StringCmd = red.StringCmd
|
StringCmd = red.StringCmd
|
||||||
// Script is an alias of redis.Script.
|
// Script is an alias of redis.Script.
|
||||||
Script = red.Script
|
Script = red.Script
|
||||||
|
|
||||||
|
// Hook is an alias of redis.Hook.
|
||||||
|
Hook = red.Hook
|
||||||
|
// DialHook is an alias of redis.DialHook.
|
||||||
|
DialHook = red.DialHook
|
||||||
|
// ProcessHook is an alias of redis.ProcessHook.
|
||||||
|
ProcessHook = red.ProcessHook
|
||||||
|
// ProcessPipelineHook is an alias of redis.ProcessPipelineHook.
|
||||||
|
ProcessPipelineHook = red.ProcessPipelineHook
|
||||||
|
|
||||||
|
// Cmder is an alias of redis.Cmder.
|
||||||
|
Cmder = red.Cmder
|
||||||
)
|
)
|
||||||
|
|
||||||
// MustNewRedis returns a Redis with given options.
|
// MustNewRedis returns a Redis with given options.
|
||||||
@ -2363,9 +2375,9 @@ func WithTLS() Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// withHook customizes the given Redis with given durationHook, only for private use now,
|
// WithHook customizes the given Redis with given durationHook, only for private use now,
|
||||||
// maybe expose later.
|
// maybe expose later.
|
||||||
func withHook(hook red.Hook) Option {
|
func WithHook(hook Hook) Option {
|
||||||
return func(r *Redis) {
|
return func(r *Redis) {
|
||||||
r.hooks = append(r.hooks, hook)
|
r.hooks = append(r.hooks, hook)
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ func TestRedis_NonBlock(t *testing.T) {
|
|||||||
Host: s.Addr(),
|
Host: s.Addr(),
|
||||||
NonBlock: true,
|
NonBlock: true,
|
||||||
Type: NodeType,
|
Type: NodeType,
|
||||||
}, withHook(myHook{includePing: true}))
|
}, WithHook(myHook{includePing: true}))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ func TestRedis_NonBlock(t *testing.T) {
|
|||||||
Host: s.Addr(),
|
Host: s.Addr(),
|
||||||
NonBlock: false,
|
NonBlock: false,
|
||||||
Type: NodeType,
|
Type: NodeType,
|
||||||
}, withHook(myHook{includePing: true}))
|
}, WithHook(myHook{includePing: true}))
|
||||||
assert.ErrorContains(t, err, "redis connect error")
|
assert.ErrorContains(t, err, "redis connect error")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user