PUnsubscribe the client from the given patterns, or from all of them if none is given.
(ctx context.Context, patterns ...string)
| 296 | // PUnsubscribe the client from the given patterns, or from all of |
| 297 | // them if none is given. |
| 298 | func (c *PubSub) PUnsubscribe(ctx context.Context, patterns ...string) error { |
| 299 | c.mu.Lock() |
| 300 | defer c.mu.Unlock() |
| 301 | |
| 302 | if len(patterns) > 0 { |
| 303 | for _, pattern := range patterns { |
| 304 | delete(c.patterns, pattern) |
| 305 | } |
| 306 | } else { |
| 307 | // Unsubscribe from all patterns. |
| 308 | clear(c.patterns) |
| 309 | } |
| 310 | |
| 311 | err := c.subscribe(ctx, "punsubscribe", patterns...) |
| 312 | return err |
| 313 | } |
| 314 | |
| 315 | // SUnsubscribe unsubscribes the client from the given shard channels, |
| 316 | // or from all of them if none is given. |