(addrs []map[string]string, keepDisconnected bool)
| 1082 | } |
| 1083 | |
| 1084 | func parseReplicaAddrs(addrs []map[string]string, keepDisconnected bool) []string { |
| 1085 | nodes := make([]string, 0, len(addrs)) |
| 1086 | for _, node := range addrs { |
| 1087 | isDown := false |
| 1088 | if flags, ok := node["flags"]; ok { |
| 1089 | for _, flag := range strings.Split(flags, ",") { |
| 1090 | switch flag { |
| 1091 | case "s_down", "o_down": |
| 1092 | isDown = true |
| 1093 | case "disconnected": |
| 1094 | if !keepDisconnected { |
| 1095 | isDown = true |
| 1096 | } |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | if !isDown && node["ip"] != "" && node["port"] != "" { |
| 1101 | nodes = append(nodes, net.JoinHostPort(node["ip"], node["port"])) |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | return nodes |
| 1106 | } |
| 1107 | |
| 1108 | func (c *sentinelFailover) trySwitchMaster(ctx context.Context, addr string) { |
| 1109 | c.mu.RLock() |
no outgoing calls
searching dependent graphs…