fixup set connected in hook
Some checks failed
codeql / analyze (go) (push) Failing after 48s
build / test (push) Failing after 4m57s
build / lint (push) Successful in 9m38s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-11-28 09:53:03 +03:00
parent 7fc5a26347
commit cbf00a0981

View File

@ -37,9 +37,14 @@ func (h *eventHook) DialHook(hook goredis.DialHook) goredis.DialHook {
func (h *eventHook) ProcessHook(hook goredis.ProcessHook) goredis.ProcessHook {
return func(ctx context.Context, cmd goredis.Cmder) error {
err := hook(ctx, cmd)
if err != nil && !isRedisError(err) {
if err != nil {
if !isRedisError(err) {
h.connected.Store(false)
}
h.connected.Store(true)
} else {
h.connected.Store(true)
}
return err
}
}
@ -47,9 +52,14 @@ func (h *eventHook) ProcessHook(hook goredis.ProcessHook) goredis.ProcessHook {
func (h *eventHook) ProcessPipelineHook(hook goredis.ProcessPipelineHook) goredis.ProcessPipelineHook {
return func(ctx context.Context, cmds []goredis.Cmder) error {
err := hook(ctx, cmds)
if err != nil && !isRedisError(err) {
if err != nil {
if !isRedisError(err) {
h.connected.Store(false)
}
h.connected.Store(true)
} else {
h.connected.Store(true)
}
return err
}
}