mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Remove Redis Cluster state check
This commit is contained in:
@ -3,6 +3,7 @@ package redis
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/go-redis/redis/internal/hashtag"
|
||||
"github.com/go-redis/redis/internal/pool"
|
||||
@ -55,3 +56,27 @@ func (c *ClusterClient) SwapNodes(key string) error {
|
||||
nodes[0], nodes[1] = nodes[1], nodes[0]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (state *clusterState) IsConsistent() bool {
|
||||
if len(state.Masters) < 3 {
|
||||
return false
|
||||
}
|
||||
for _, master := range state.Masters {
|
||||
s := master.Client.Info("replication").Val()
|
||||
if !strings.Contains(s, "role:master") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if len(state.Slaves) < 3 {
|
||||
return false
|
||||
}
|
||||
for _, slave := range state.Slaves {
|
||||
s := slave.Client.Info("replication").Val()
|
||||
if !strings.Contains(s, "role:slave") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user