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

Method Subscribe

ring.go:677–688  ·  view source on GitHub ↗

Subscribe subscribes the client to the specified channels.

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

Source from the content-addressed store, hash-verified

675
676// Subscribe subscribes the client to the specified channels.
677func (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.
691func (c *Ring) PSubscribe(ctx context.Context, channels ...string) *PubSub {

Callers

nothing calls this directly

Calls 2

GetByKeyMethod · 0.80
SubscribeMethod · 0.65

Tested by

no test coverage detected