mirror of
https://github.com/redis/go-redis.git
synced 2025-06-12 14:21:52 +03:00
Set read/write timeouts more consistently.
This commit is contained in:
25
pipeline.go
25
pipeline.go
@ -1,9 +1,9 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"gopkg.in/redis.v5/internal"
|
||||
"gopkg.in/redis.v5/internal/pool"
|
||||
)
|
||||
|
||||
@ -67,7 +67,7 @@ func (c *Pipeline) Exec() ([]Cmder, error) {
|
||||
}
|
||||
|
||||
if len(c.cmds) == 0 {
|
||||
return c.cmds, nil
|
||||
return nil, errors.New("redis: pipeline is empty")
|
||||
}
|
||||
|
||||
cmds := c.cmds
|
||||
@ -84,24 +84,3 @@ func (c *Pipeline) pipelined(fn func(*Pipeline) error) ([]Cmder, error) {
|
||||
_ = c.Close()
|
||||
return cmds, err
|
||||
}
|
||||
|
||||
func execCmds(cn *pool.Conn, cmds []Cmder) (retry bool, firstErr error) {
|
||||
if err := writeCmd(cn, cmds...); err != nil {
|
||||
setCmdsErr(cmds, err)
|
||||
return true, err
|
||||
}
|
||||
|
||||
for i, cmd := range cmds {
|
||||
err := cmd.readReply(cn)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
if i == 0 && internal.IsNetworkError(err) {
|
||||
return true, err
|
||||
}
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
}
|
||||
return false, firstErr
|
||||
}
|
||||
|
Reference in New Issue
Block a user