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

Method IsConsistent

export_test.go:63–85  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

61}
62
63func (c *clusterState) IsConsistent(ctx context.Context) bool {
64 if len(c.Masters) < 3 {
65 return false
66 }
67 for _, master := range c.Masters {
68 s := master.Client.Info(ctx, "replication").Val()
69 if !strings.Contains(s, "role:master") {
70 return false
71 }
72 }
73
74 if len(c.Slaves) < 3 {
75 return false
76 }
77 for _, slave := range c.Slaves {
78 s := slave.Client.Info(ctx, "replication").Val()
79 if !strings.Contains(s, "role:slave") {
80 return false
81 }
82 }
83
84 return true
85}
86
87func GetSlavesAddrByName(ctx context.Context, c *SentinelClient, name string) []string {
88 addrs, err := c.Replicas(ctx, name).Result()

Callers 1

newClusterClientMethod · 0.80

Calls 3

InfoMethod · 0.65
ValMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected