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

Method initHealthCheck

pubsub.go:714–746  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

712}
713
714func (c *channel) initHealthCheck() {
715 c.ping = make(chan struct{}, 1)
716
717 go func() {
718 timer := time.NewTimer(time.Minute)
719 timer.Stop()
720
721 for {
722 timer.Reset(c.checkInterval)
723 select {
724 case <-c.ping:
725 select {
726 case <-timer.C:
727 default:
728 }
729 case <-timer.C:
730 ctx, cancel := context.WithTimeout(context.Background(), c.pingTimeout)
731 pingErr := c.pubSub.Ping(ctx)
732 cancel()
733
734 if pingErr != nil {
735 c.pubSub.mu.Lock()
736 reconnectCtx, reconnectCancel := context.WithTimeout(context.Background(), c.reconnectTimeout)
737 c.pubSub.reconnect(reconnectCtx, pingErr)
738 reconnectCancel()
739 c.pubSub.mu.Unlock()
740 }
741 case <-c.pubSub.exit:
742 return
743 }
744 }
745 }()
746}
747
748// initMsgChan must be in sync with initAllChan.
749func (c *channel) initMsgChan() {

Callers 1

newChannelFunction · 0.95

Calls 5

WithTimeoutMethod · 0.80
reconnectMethod · 0.80
StopMethod · 0.65
PingMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected