mirror of
https://github.com/redis/go-redis.git
synced 2025-06-12 14:21:52 +03:00
Add latency based routing to Redis Cluster client.
This commit is contained in:
committed by
Vladimir Mihailenco
parent
3972f28066
commit
487feebef1
8
redis.go
8
redis.go
@ -52,7 +52,7 @@ func (c *baseClient) putConn(cn *pool.Conn, err error, allowTimeout bool) bool {
|
||||
func (c *baseClient) initConn(cn *pool.Conn) error {
|
||||
cn.Inited = true
|
||||
|
||||
if c.opt.Password == "" && c.opt.DB == 0 {
|
||||
if c.opt.Password == "" && c.opt.DB == 0 && !c.opt.ReadOnly {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -71,6 +71,12 @@ func (c *baseClient) initConn(cn *pool.Conn) error {
|
||||
}
|
||||
}
|
||||
|
||||
if c.opt.ReadOnly {
|
||||
if err := client.ReadOnly().Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user