MCPcopy
hub / github.com/redis/go-redis / parseReplicaAddrs

Function parseReplicaAddrs

sentinel.go:1084–1106  ·  view source on GitHub ↗
(addrs []map[string]string, keepDisconnected bool)

Source from the content-addressed store, hash-verified

1082}
1083
1084func 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
1108func (c *sentinelFailover) trySwitchMaster(ctx context.Context, addr string) {
1109 c.mu.RLock()

Callers 3

GetSlavesAddrByNameFunction · 0.85
replicaAddrsMethod · 0.85
getReplicaAddrsMethod · 0.85

Calls

no outgoing calls

Tested by 1

GetSlavesAddrByNameFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…