Skip to content

Commit 93c01ea

Browse files
committed
fixed GetNumberSentinelSlavesInMemory
1 parent af94a65 commit 93c01ea

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/client/redis/client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,18 @@ func (c *client) GetNumberSentinelSlavesInMemory(ip string, auth *util.AuthConfi
104104
return 0, err
105105
}
106106
nSlaves := 0
107+
OUTER:
107108
for _, slaveInfoBlob := range slaveInfoBlobs {
108109
slaveInfo := reflect.ValueOf(slaveInfoBlob)
109-
slavePriority := fmt.Sprintf("%+v", slaveInfo.Index(37))
110-
if slavePriority == "1" {
111-
nSlaves += 1
110+
for key, value := range slaveInfoBlob.([]interface{}) {
111+
stringValue := value.(string)
112+
if stringValue == "slave-priority" {
113+
slavePriority := fmt.Sprintf("%+v", slaveInfo.Index(key+1))
114+
if slavePriority == "1" {
115+
nSlaves += 1
116+
}
117+
continue OUTER
118+
}
112119
}
113120
}
114121

0 commit comments

Comments
 (0)