(ctx context.Context, reason error)
| 182 | } |
| 183 | |
| 184 | func (c *PubSub) reconnect(ctx context.Context, reason error) { |
| 185 | if c.cn != nil && c.cn.ShouldHandoff() { |
| 186 | newEndpoint := c.cn.GetHandoffEndpoint() |
| 187 | // If new endpoint is NULL, use the original address |
| 188 | if newEndpoint == internal.RedisNull { |
| 189 | newEndpoint = c.opt.Addr |
| 190 | } |
| 191 | |
| 192 | if newEndpoint != "" { |
| 193 | // Update the address in the options |
| 194 | oldAddr := c.cn.RemoteAddr().String() |
| 195 | c.opt.Addr = newEndpoint |
| 196 | internal.Logger.Printf(ctx, "pubsub: reconnecting to new endpoint %s (was %s)", newEndpoint, oldAddr) |
| 197 | } |
| 198 | } |
| 199 | _ = c.closeTheCn(reason) |
| 200 | _, _ = c.conn(ctx, nil) |
| 201 | } |
| 202 | |
| 203 | func (c *PubSub) closeTheCn(reason error) error { |
| 204 | if c.cn == nil { |
no test coverage detected