Unsubscribe the client from the given channels, or from all of them if none is given.
(ctx context.Context, channels ...string)
| 277 | // Unsubscribe the client from the given channels, or from all of |
| 278 | // them if none is given. |
| 279 | func (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. |
no test coverage detected