1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Move Publish channel to cmdable. Remove method that was deprecated in v3.

This commit is contained in:
Vladimir Mihailenco
2016-07-21 13:04:40 +00:00
parent eca5d02f24
commit 4210c090b1
5 changed files with 37 additions and 34 deletions

View File

@ -10,13 +10,6 @@ import (
"gopkg.in/redis.v4/internal/pool"
)
// Posts a message to the given channel.
func (c *Client) Publish(channel, message string) *IntCmd {
req := NewIntCmd("PUBLISH", channel, message)
c.Process(req)
return req
}
// PubSub implements Pub/Sub commands as described in
// http://redis.io/topics/pubsub. It's NOT safe for concurrent use by
// multiple goroutines.
@ -29,28 +22,6 @@ type PubSub struct {
nsub int // number of active subscriptions
}
// Deprecated. Use Subscribe/PSubscribe instead.
func (c *Client) PubSub() *PubSub {
return &PubSub{
base: baseClient{
opt: c.opt,
connPool: pool.NewStickyConnPool(c.connPool.(*pool.ConnPool), false),
},
}
}
// Subscribes the client to the specified channels.
func (c *Client) Subscribe(channels ...string) (*PubSub, error) {
pubsub := c.PubSub()
return pubsub, pubsub.Subscribe(channels...)
}
// Subscribes the client to the given patterns.
func (c *Client) PSubscribe(channels ...string) (*PubSub, error) {
pubsub := c.PubSub()
return pubsub, pubsub.PSubscribe(channels...)
}
func (c *PubSub) subscribe(redisCmd string, channels ...string) error {
cn, err := c.base.conn()
if err != nil {