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

Method pubSub

sentinel.go:679–708  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

677}
678
679func (c *SentinelClient) pubSub() *PubSub {
680 pubsub := &PubSub{
681 opt: c.opt,
682 newConn: func(ctx context.Context, addr string, channels []string) (*pool.Conn, error) {
683 cn, err := c.pubSubPool.NewConn(ctx, c.opt.Network, addr, channels)
684 if err != nil {
685 return nil, err
686 }
687 // will return nil if already initialized
688 err = c.initConn(ctx, cn)
689 if err != nil {
690 _ = cn.Close()
691 return nil, err
692 }
693 // Track connection in PubSubPool
694 c.pubSubPool.TrackConn(cn)
695 return cn, nil
696 },
697 closeConn: func(cn *pool.Conn) error {
698 // Untrack connection from PubSubPool
699 c.pubSubPool.UntrackConn(cn)
700 _ = cn.Close()
701 return nil
702 },
703 pushProcessor: c.pushProcessor,
704 }
705 pubsub.init()
706
707 return pubsub
708}
709
710// Ping is used to test if a connection is still alive, or to
711// measure latency.

Callers 2

SubscribeMethod · 0.95
PSubscribeMethod · 0.95

Calls 6

CloseMethod · 0.95
initMethod · 0.95
initConnMethod · 0.80
TrackConnMethod · 0.80
UntrackConnMethod · 0.80
NewConnMethod · 0.65

Tested by

no test coverage detected