From 7fc5a263474915f8da0bedfa1a77edd1a43bcbd5 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 28 Nov 2024 09:49:29 +0300 Subject: [PATCH] fixup set connected in hook Signed-off-by: Vasiliy Tolstov --- event.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/event.go b/event.go index 6f1de6d..3142956 100644 --- a/event.go +++ b/event.go @@ -22,8 +22,13 @@ func newEventHook(connected *atomic.Bool) *eventHook { func (h *eventHook) DialHook(hook goredis.DialHook) goredis.DialHook { return func(ctx context.Context, network, addr string) (net.Conn, error) { conn, err := hook(ctx, network, addr) - 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 conn, err }