mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Use simple PING for compatibility
This commit is contained in:
@ -98,10 +98,10 @@ func (c *PubSub) Close() error {
|
|||||||
return c.base.Close()
|
return c.base.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PubSub) Ping(payload string) error {
|
func (c *PubSub) Ping(payload ...string) error {
|
||||||
args := []interface{}{"PING"}
|
args := []interface{}{"PING"}
|
||||||
if payload != "" {
|
if len(payload) == 1 {
|
||||||
args = append(args, payload)
|
args = append(args, payload[0])
|
||||||
}
|
}
|
||||||
cmd := NewCmd(args...)
|
cmd := NewCmd(args...)
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ func (c *PubSub) receiveMessage(timeout time.Duration) (*Message, error) {
|
|||||||
errNum++
|
errNum++
|
||||||
if errNum < 3 {
|
if errNum < 3 {
|
||||||
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
||||||
err := c.Ping("hello")
|
err := c.Ping()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
internal.Logf("PubSub.Ping failed: %s", err)
|
internal.Logf("PubSub.Ping failed: %s", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user