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
|
idleTimeoutSec = 240
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connStr := s.ConnStr()
|
||||||
|
|
||||||
|
if len(s.Prefix) > 0 {
|
||||||
|
logger = logger.WithName("[" + s.Prefix + "]")
|
||||||
|
}
|
||||||
|
|
||||||
return &redis.Pool{
|
return &redis.Pool{
|
||||||
Wait: false,
|
Wait: false,
|
||||||
MaxIdle: maxIdle,
|
MaxIdle: maxIdle,
|
||||||
IdleTimeout: time.Second * time.Duration(idleTimeoutSec),
|
IdleTimeout: time.Second * time.Duration(idleTimeoutSec),
|
||||||
Dial: func() (redis.Conn, error) {
|
Dial: func() (redis.Conn, error) {
|
||||||
orig, err := redis.Dial("tcp", s.ConnStr())
|
orig, err := redis.Dial("tcp", connStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
if len(s.Prefix) > 0 {
|
|
||||||
logger = logger.WithName("[" + s.Prefix + "]")
|
|
||||||
}
|
|
||||||
c := &rdb{
|
c := &rdb{
|
||||||
orig: orig,
|
orig: orig,
|
||||||
name: s.Prefix,
|
name: s.Prefix,
|
||||||
|
|
Loading…
Reference in New Issue