Moving conn str and log config out of the pool thread func
This commit is contained in:
parent
5eef4a59f5
commit
8c1374c7c9
11
rdb.go
11
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,
|
||||
|
|
Loading…
Reference in New Issue