(ctx context.Context)
| 1141 | } |
| 1142 | |
| 1143 | func (c *sentinelFailover) discoverSentinels(ctx context.Context) { |
| 1144 | sentinels, err := c.sentinel.Sentinels(ctx, c.opt.MasterName).Result() |
| 1145 | if err != nil { |
| 1146 | internal.Logger.Printf(ctx, "sentinel: Sentinels master=%q failed: %s", c.opt.MasterName, err) |
| 1147 | return |
| 1148 | } |
| 1149 | for _, sentinel := range sentinels { |
| 1150 | ip, ok := sentinel["ip"] |
| 1151 | if !ok { |
| 1152 | continue |
| 1153 | } |
| 1154 | port, ok := sentinel["port"] |
| 1155 | if !ok { |
| 1156 | continue |
| 1157 | } |
| 1158 | if ip != "" && port != "" { |
| 1159 | sentinelAddr := net.JoinHostPort(ip, port) |
| 1160 | if !slices.Contains(c.sentinelAddrs, sentinelAddr) { |
| 1161 | internal.Logger.Printf(ctx, "sentinel: discovered new sentinel=%q for master=%q", |
| 1162 | sentinelAddr, c.opt.MasterName) |
| 1163 | c.sentinelAddrs = append(c.sentinelAddrs, sentinelAddr) |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | func (c *sentinelFailover) listen(pubsub *PubSub) { |
| 1170 | ctx := context.TODO() |
no test coverage detected