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

Method reconnect

pubsub.go:184–201  ·  view source on GitHub ↗
(ctx context.Context, reason error)

Source from the content-addressed store, hash-verified

182}
183
184func (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
203func (c *PubSub) closeTheCn(reason error) error {
204 if c.cn == nil {

Callers 2

releaseConnMethod · 0.95
initHealthCheckMethod · 0.80

Calls 7

closeTheCnMethod · 0.95
connMethod · 0.95
ShouldHandoffMethod · 0.80
GetHandoffEndpointMethod · 0.80
StringMethod · 0.65
RemoteAddrMethod · 0.65
PrintfMethod · 0.65

Tested by

no test coverage detected