diff --git a/v2/multi.go b/v2/multi.go index 926fd8f..d61ceb6 100644 --- a/v2/multi.go +++ b/v2/multi.go @@ -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 { diff --git a/v2/pipeline.go b/v2/pipeline.go index 4ae0c08..6922b33 100644 --- a/v2/pipeline.go +++ b/v2/pipeline.go @@ -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 { diff --git a/v2/pool.go b/v2/pool.go index 4fb83a7..a4c7df1 100644 --- a/v2/pool.go +++ b/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() } //------------------------------------------------------------------------------ diff --git a/v2/pubsub.go b/v2/pubsub.go index e886d19..07bf51a 100644 --- a/v2/pubsub.go +++ b/v2/pubsub.go @@ -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 } diff --git a/v2/redis.go b/v2/redis.go index 072070d..b1b54f4 100644 --- a/v2/redis.go +++ b/v2/redis.go @@ -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)