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

Method SUnsubscribe

pubsub.go:317–332  ·  view source on GitHub ↗

SUnsubscribe unsubscribes the client from the given shard channels, or from all of them if none is given.

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

Source from the content-addressed store, hash-verified

315// SUnsubscribe unsubscribes the client from the given shard channels,
316// or from all of them if none is given.
317func (c *PubSub) SUnsubscribe(ctx context.Context, channels ...string) error {
318 c.mu.Lock()
319 defer c.mu.Unlock()
320
321 if len(channels) > 0 {
322 for _, channel := range channels {
323 delete(c.schannels, channel)
324 }
325 } else {
326 // Unsubscribe from all channels.
327 clear(c.schannels)
328 }
329
330 err := c.subscribe(ctx, "sunsubscribe", channels...)
331 return err
332}
333
334func (c *PubSub) subscribe(ctx context.Context, redisCmd string, channels ...string) error {
335 cn, err := c.conn(ctx, channels)

Callers 1

pubsub_test.goFile · 0.80

Calls 1

subscribeMethod · 0.95

Tested by

no test coverage detected