mirror of https://github.com/go-redis/redis.git
Merge pull request #1693 from monkey92t/sentinel
discoverSentinels read the addr field incorrectly
This commit is contained in:
commit
f63e0d666b
13
sentinel.go
13
sentinel.go
|
@ -666,10 +666,18 @@ func (c *sentinelFailover) discoverSentinels(ctx context.Context) {
|
||||||
}
|
}
|
||||||
for _, sentinel := range sentinels {
|
for _, sentinel := range sentinels {
|
||||||
vals := sentinel.([]interface{})
|
vals := sentinel.([]interface{})
|
||||||
|
var ip, port string
|
||||||
for i := 0; i < len(vals); i += 2 {
|
for i := 0; i < len(vals); i += 2 {
|
||||||
key := vals[i].(string)
|
key := vals[i].(string)
|
||||||
if key == "name" {
|
switch key {
|
||||||
sentinelAddr := vals[i+1].(string)
|
case "ip":
|
||||||
|
ip = vals[i+1].(string)
|
||||||
|
case "port":
|
||||||
|
port = vals[i+1].(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ip != "" && port != "" {
|
||||||
|
sentinelAddr := net.JoinHostPort(ip, port)
|
||||||
if !contains(c.sentinelAddrs, sentinelAddr) {
|
if !contains(c.sentinelAddrs, sentinelAddr) {
|
||||||
internal.Logger.Printf(ctx, "sentinel: discovered new sentinel=%q for master=%q",
|
internal.Logger.Printf(ctx, "sentinel: discovered new sentinel=%q for master=%q",
|
||||||
sentinelAddr, c.opt.MasterName)
|
sentinelAddr, c.opt.MasterName)
|
||||||
|
@ -677,7 +685,6 @@ func (c *sentinelFailover) discoverSentinels(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sentinelFailover) listen(pubsub *PubSub) {
|
func (c *sentinelFailover) listen(pubsub *PubSub) {
|
||||||
|
|
Loading…
Reference in New Issue