Merge pull request #511 from go-redis/fix/simple-ping

Use simple PING for compatibility
This commit is contained in:
Vladimir Mihailenco 2017-02-23 16:37:17 +03:00 committed by GitHub
commit fe9d145e7c
1 changed files with 4 additions and 4 deletions

View File

@ -98,10 +98,10 @@ func (c *PubSub) Close() error {
return c.base.Close()
}
func (c *PubSub) Ping(payload string) error {
func (c *PubSub) Ping(payload ...string) error {
args := []interface{}{"PING"}
if payload != "" {
args = append(args, payload)
if len(payload) == 1 {
args = append(args, payload[0])
}
cmd := NewCmd(args...)
@ -239,7 +239,7 @@ func (c *PubSub) receiveMessage(timeout time.Duration) (*Message, error) {
errNum++
if errNum < 3 {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
err := c.Ping("hello")
err := c.Ping()
if err != nil {
internal.Logf("PubSub.Ping failed: %s", err)
}