mirror of https://github.com/go-redis/redis.git
Lower case few fields for consistency.
This commit is contained in:
parent
773f2a03f3
commit
f54394beb6
|
@ -91,14 +91,14 @@ func (c *Multi) execCmds(cmds []Cmder, cn *conn) error {
|
|||
|
||||
// Parse queued replies.
|
||||
for i := 0; i < cmdsLen; i++ {
|
||||
_, err = statusCmd.parseReply(cn.Rd)
|
||||
_, err = statusCmd.parseReply(cn.rd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Parse number of replies.
|
||||
line, err := readLine(cn.Rd)
|
||||
line, err := readLine(cn.rd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func (c *Multi) execCmds(cmds []Cmder, cn *conn) error {
|
|||
// Loop starts from 1 to omit first cmduest (MULTI).
|
||||
for i := 1; i < cmdsLen; i++ {
|
||||
cmd := cmds[i]
|
||||
val, err := cmd.parseReply(cn.Rd)
|
||||
val, err := cmd.parseReply(cn.rd)
|
||||
if err != nil {
|
||||
cmd.setErr(err)
|
||||
} else {
|
||||
|
|
|
@ -70,7 +70,7 @@ func (c *Pipeline) execCmds(cmds []Cmder, cn *conn) error {
|
|||
|
||||
var firstCmdErr error
|
||||
for _, cmd := range cmds {
|
||||
val, err := cmd.parseReply(cn.Rd)
|
||||
val, err := cmd.parseReply(cn.rd)
|
||||
if err != nil {
|
||||
cmd.setErr(err)
|
||||
if firstCmdErr == nil {
|
||||
|
|
33
v2/pool.go
33
v2/pool.go
|
@ -20,38 +20,37 @@ type pool interface {
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
type conn struct {
|
||||
Cn net.Conn
|
||||
Rd reader
|
||||
|
||||
UsedAt time.Time
|
||||
cn net.Conn
|
||||
rd reader
|
||||
usedAt time.Time
|
||||
|
||||
readTimeout, writeTimeout time.Duration
|
||||
}
|
||||
|
||||
func newConn(netcn net.Conn) *conn {
|
||||
cn := &conn{
|
||||
Cn: netcn,
|
||||
cn: netcn,
|
||||
}
|
||||
cn.Rd = bufio.NewReaderSize(cn, 1024)
|
||||
cn.rd = bufio.NewReaderSize(cn, 1024)
|
||||
return cn
|
||||
}
|
||||
|
||||
func (cn *conn) Read(b []byte) (int, error) {
|
||||
if cn.readTimeout != 0 {
|
||||
cn.Cn.SetReadDeadline(time.Now().Add(cn.readTimeout))
|
||||
cn.cn.SetReadDeadline(time.Now().Add(cn.readTimeout))
|
||||
} else {
|
||||
cn.Cn.SetReadDeadline(time.Time{})
|
||||
cn.cn.SetReadDeadline(time.Time{})
|
||||
}
|
||||
return cn.Cn.Read(b)
|
||||
return cn.cn.Read(b)
|
||||
}
|
||||
|
||||
func (cn *conn) Write(b []byte) (int, error) {
|
||||
if cn.writeTimeout != 0 {
|
||||
cn.Cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout))
|
||||
cn.cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout))
|
||||
} else {
|
||||
cn.Cn.SetReadDeadline(time.Time{})
|
||||
cn.cn.SetReadDeadline(time.Time{})
|
||||
}
|
||||
return cn.Cn.Write(b)
|
||||
return cn.cn.Write(b)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -93,7 +92,7 @@ func (p *connPool) Get() (*conn, bool, error) {
|
|||
if p.idleTimeout > 0 {
|
||||
for e := p.conns.Front(); e != nil; e = e.Next() {
|
||||
cn := e.Value.(*conn)
|
||||
if time.Since(cn.UsedAt) > p.idleTimeout {
|
||||
if time.Since(cn.usedAt) > p.idleTimeout {
|
||||
p.conns.Remove(e)
|
||||
}
|
||||
}
|
||||
|
@ -115,12 +114,12 @@ func (p *connPool) Get() (*conn, bool, error) {
|
|||
}
|
||||
|
||||
func (p *connPool) Put(cn *conn) error {
|
||||
if cn.Rd.Buffered() != 0 {
|
||||
panic("pool: attempt to put connection with buffered data")
|
||||
if cn.rd.Buffered() != 0 {
|
||||
panic("redis: attempt to put connection with buffered data")
|
||||
}
|
||||
|
||||
p.cond.L.Lock()
|
||||
cn.UsedAt = time.Now()
|
||||
cn.usedAt = time.Now()
|
||||
p.conns.PushFront(cn)
|
||||
p.cond.Signal()
|
||||
p.cond.L.Unlock()
|
||||
|
@ -167,7 +166,7 @@ func (p *connPool) Close() error {
|
|||
}
|
||||
|
||||
func (p *connPool) closeConn(cn *conn) error {
|
||||
return cn.Cn.Close()
|
||||
return cn.cn.Close()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -52,7 +52,7 @@ func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error) {
|
|||
}
|
||||
cn.readTimeout = timeout
|
||||
|
||||
replyIface, err := NewSliceCmd().parseReply(cn.Rd)
|
||||
replyIface, err := NewSliceCmd().parseReply(cn.rd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func (c *baseClient) run(cmd Cmder) {
|
|||
return
|
||||
}
|
||||
|
||||
val, err := cmd.parseReply(cn.Rd)
|
||||
val, err := cmd.parseReply(cn.rd)
|
||||
if err != nil {
|
||||
c.freeConn(cn, err)
|
||||
cmd.setErr(err)
|
||||
|
|
Loading…
Reference in New Issue