Subscribe subscribes the client to the specified channels.
(ctx context.Context, channels ...string)
| 675 | |
| 676 | // Subscribe subscribes the client to the specified channels. |
| 677 | func (c *Ring) Subscribe(ctx context.Context, channels ...string) *PubSub { |
| 678 | if len(channels) == 0 { |
| 679 | panic("at least one channel is required") |
| 680 | } |
| 681 | |
| 682 | shard, err := c.sharding.GetByKey(channels[0]) |
| 683 | if err != nil { |
| 684 | // TODO: return PubSub with sticky error |
| 685 | panic(err) |
| 686 | } |
| 687 | return shard.Client.Subscribe(ctx, channels...) |
| 688 | } |
| 689 | |
| 690 | // PSubscribe subscribes the client to the given patterns. |
| 691 | func (c *Ring) PSubscribe(ctx context.Context, channels ...string) *PubSub { |