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

Method Unsubscribe

pubsub.go:279–294  ·  view source on GitHub ↗

Unsubscribe the client from the given channels, or from all of them if none is given.

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

Source from the content-addressed store, hash-verified

277// Unsubscribe the client from the given channels, or from all of
278// them if none is given.
279func (c *PubSub) Unsubscribe(ctx context.Context, channels ...string) error {
280 c.mu.Lock()
281 defer c.mu.Unlock()
282
283 if len(channels) > 0 {
284 for _, channel := range channels {
285 delete(c.channels, channel)
286 }
287 } else {
288 // Unsubscribe from all channels.
289 clear(c.channels)
290 }
291
292 err := c.subscribe(ctx, "unsubscribe", channels...)
293 return err
294}
295
296// PUnsubscribe the client from the given patterns, or from all of
297// them if none is given.

Callers 2

pubsub_test.goFile · 0.80
race_test.goFile · 0.80

Calls 1

subscribeMethod · 0.95

Tested by

no test coverage detected