(ctx context.Context)
| 61 | } |
| 62 | |
| 63 | func (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 | |
| 87 | func GetSlavesAddrByName(ctx context.Context, c *SentinelClient, name string) []string { |
| 88 | addrs, err := c.Replicas(ctx, name).Result() |
no test coverage detected