forked from mirror/redis
discoverSentinels read the addr field incorrectly
Signed-off-by: monkey <golang@88.com>
This commit is contained in:
parent
573638ff0c
commit
c25daee5e6
21
sentinel.go
21
sentinel.go
|
@ -666,15 +666,22 @@ 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":
|
||||||
if !contains(c.sentinelAddrs, sentinelAddr) {
|
ip = vals[i+1].(string)
|
||||||
internal.Logger.Printf(ctx, "sentinel: discovered new sentinel=%q for master=%q",
|
case "port":
|
||||||
sentinelAddr, c.opt.MasterName)
|
port = vals[i+1].(string)
|
||||||
c.sentinelAddrs = append(c.sentinelAddrs, sentinelAddr)
|
}
|
||||||
}
|
}
|
||||||
|
if ip != "" && port != "" {
|
||||||
|
sentinelAddr := net.JoinHostPort(ip, port)
|
||||||
|
if !contains(c.sentinelAddrs, sentinelAddr) {
|
||||||
|
internal.Logger.Printf(ctx, "sentinel: discovered new sentinel=%q for master=%q",
|
||||||
|
sentinelAddr, c.opt.MasterName)
|
||||||
|
c.sentinelAddrs = append(c.sentinelAddrs, sentinelAddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue