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

Method Subscribe

pubsub.go:232–244  ·  view source on GitHub ↗

Subscribe the client to the specified channels. It returns empty subscription if there are no channels.

(ctx context.Context, channels ...string)

Source from the content-addressed store, hash-verified

230// Subscribe the client to the specified channels. It returns
231// empty subscription if there are no channels.
232func (c *PubSub) Subscribe(ctx context.Context, channels ...string) error {
233 c.mu.Lock()
234 defer c.mu.Unlock()
235
236 err := c.subscribe(ctx, "subscribe", channels...)
237 if c.channels == nil {
238 c.channels = make(map[string]struct{})
239 }
240 for _, s := range channels {
241 c.channels[s] = struct{}{}
242 }
243 return err
244}
245
246// PSubscribe the client to the given patterns. It returns
247// empty subscription if there are no patterns.

Callers

nothing calls this directly

Calls 1

subscribeMethod · 0.95

Tested by

no test coverage detected