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

Struct PubSub

pubsub.go:25–51  ·  view source on GitHub ↗

PubSub implements Pub/Sub commands as described in https://redis.io/docs/latest/develop/pubsub. Message receiving is NOT safe for concurrent use by multiple goroutines. PubSub automatically reconnects to Redis Server and resubscribes to the channels in case of network errors.

Source from the content-addressed store, hash-verified

23// PubSub automatically reconnects to Redis Server and resubscribes
24// to the channels in case of network errors.
25type PubSub struct {
26 opt *Options
27
28 newConn func(ctx context.Context, addr string, channels []string) (*pool.Conn, error)
29 closeConn func(*pool.Conn) error
30
31 mu sync.Mutex
32 cn *pool.Conn
33 channels map[string]struct{}
34 patterns map[string]struct{}
35 schannels map[string]struct{}
36
37 closed bool
38 exit chan struct{}
39
40 cmd *Cmd
41
42 chOnce sync.Once
43 msgCh *channel
44 allCh *channel
45
46 // Push notification processor for handling generic push notifications
47 pushProcessor push.NotificationProcessor
48
49 // Cleanup callback for maintenanceNotifications upgrade tracking
50 onClose func()
51}
52
53func (c *PubSub) init() {
54 c.exit = make(chan struct{})

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected