From 8c1374c7c9ca80191d885c3dfe3fa8b1029ed87d Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Mon, 7 Nov 2022 15:18:32 +0300 Subject: [PATCH] Moving conn str and log config out of the pool thread func --- rdb.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rdb.go b/rdb.go index fca9266..90f7bfd 100644 --- a/rdb.go +++ b/rdb.go @@ -140,18 +140,21 @@ func newRedisPool(s RdSettings, logger logr.Logger) *redis.Pool { idleTimeoutSec = 240 } + connStr := s.ConnStr() + + if len(s.Prefix) > 0 { + logger = logger.WithName("[" + s.Prefix + "]") + } + return &redis.Pool{ Wait: false, MaxIdle: maxIdle, IdleTimeout: time.Second * time.Duration(idleTimeoutSec), Dial: func() (redis.Conn, error) { - orig, err := redis.Dial("tcp", s.ConnStr()) + orig, err := redis.Dial("tcp", connStr) if err != nil { return nil, errors.WithStack(err) } - if len(s.Prefix) > 0 { - logger = logger.WithName("[" + s.Prefix + "]") - } c := &rdb{ orig: orig, name: s.Prefix,