From 18c1db946601fba100ad23e98eb8c04055a2a6cd Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 11 May 2017 17:02:26 +0300 Subject: [PATCH] Doc --- pubsub.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pubsub.go b/pubsub.go index b9d5c60b..19016b9d 100644 --- a/pubsub.go +++ b/pubsub.go @@ -13,6 +13,9 @@ import ( // PubSub implements Pub/Sub commands as described in // http://redis.io/topics/pubsub. It's NOT safe for concurrent use by // multiple goroutines. +// +// PubSub automatically resubscribes to the channels and patterns +// when Redis becomes unavailable. type PubSub struct { base baseClient @@ -138,7 +141,8 @@ func (c *PubSub) _subscribe(cn *pool.Conn, redisCmd string, channels ...string) return writeCmd(cn, cmd) } -// Subscribes the client to the specified channels. +// Subscribes the client to the specified channels. It returns +// empty subscription if there are no channels. func (c *PubSub) Subscribe(channels ...string) error { c.subMu.Lock() c.channels = appendIfNotExists(c.channels, channels...) @@ -146,7 +150,8 @@ func (c *PubSub) Subscribe(channels ...string) error { return c.subscribe("subscribe", channels...) } -// Subscribes the client to the given patterns. +// Subscribes the client to the given patterns. It returns +// empty subscription if there are no patterns. func (c *PubSub) PSubscribe(patterns ...string) error { c.subMu.Lock() c.patterns = appendIfNotExists(c.patterns, patterns...)