From cbf00a0981b9c9a4c4d7149e6a878a00ad654126 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 28 Nov 2024 09:53:03 +0300 Subject: [PATCH] fixup set connected in hook Signed-off-by: Vasiliy Tolstov --- event.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/event.go b/event.go index 3142956..cdfe75e 100644 --- a/event.go +++ b/event.go @@ -37,8 +37,13 @@ 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) { - h.connected.Store(false) + if err != nil { + if !isRedisError(err) { + h.connected.Store(false) + } + h.connected.Store(true) + } else { + h.connected.Store(true) } return err } @@ -47,8 +52,13 @@ 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) { - h.connected.Store(false) + if err != nil { + if !isRedisError(err) { + h.connected.Store(false) + } + h.connected.Store(true) + } else { + h.connected.Store(true) } return err }