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.
| 23 | // PubSub automatically reconnects to Redis Server and resubscribes |
| 24 | // to the channels in case of network errors. |
| 25 | type 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 | |
| 53 | func (c *PubSub) init() { |
| 54 | c.exit = make(chan struct{}) |
nothing calls this directly
no outgoing calls
no test coverage detected