Lower case few fields for consistency.

This commit is contained in:
Vladimir Mihailenco 2013-09-29 11:11:18 +03:00
parent 773f2a03f3
commit f54394beb6
5 changed files with 22 additions and 23 deletions

View File

@ -91,14 +91,14 @@ func (c *Multi) execCmds(cmds []Cmder, cn *conn) error {
// Parse queued replies. // Parse queued replies.
for i := 0; i < cmdsLen; i++ { for i := 0; i < cmdsLen; i++ {
_, err = statusCmd.parseReply(cn.Rd) _, err = statusCmd.parseReply(cn.rd)
if err != nil { if err != nil {
return err return err
} }
} }
// Parse number of replies. // Parse number of replies.
line, err := readLine(cn.Rd) line, err := readLine(cn.rd)
if err != nil { if err != nil {
return err return err
} }
@ -113,7 +113,7 @@ func (c *Multi) execCmds(cmds []Cmder, cn *conn) error {
// Loop starts from 1 to omit first cmduest (MULTI). // Loop starts from 1 to omit first cmduest (MULTI).
for i := 1; i < cmdsLen; i++ { for i := 1; i < cmdsLen; i++ {
cmd := cmds[i] cmd := cmds[i]
val, err := cmd.parseReply(cn.Rd) val, err := cmd.parseReply(cn.rd)
if err != nil { if err != nil {
cmd.setErr(err) cmd.setErr(err)
} else { } else {

View File

@ -70,7 +70,7 @@ func (c *Pipeline) execCmds(cmds []Cmder, cn *conn) error {
var firstCmdErr error var firstCmdErr error
for _, cmd := range cmds { for _, cmd := range cmds {
val, err := cmd.parseReply(cn.Rd) val, err := cmd.parseReply(cn.rd)
if err != nil { if err != nil {
cmd.setErr(err) cmd.setErr(err)
if firstCmdErr == nil { if firstCmdErr == nil {

View File

@ -20,38 +20,37 @@ type pool interface {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
type conn struct { type conn struct {
Cn net.Conn cn net.Conn
Rd reader rd reader
usedAt time.Time
UsedAt time.Time
readTimeout, writeTimeout time.Duration readTimeout, writeTimeout time.Duration
} }
func newConn(netcn net.Conn) *conn { func newConn(netcn net.Conn) *conn {
cn := &conn{ cn := &conn{
Cn: netcn, cn: netcn,
} }
cn.Rd = bufio.NewReaderSize(cn, 1024) cn.rd = bufio.NewReaderSize(cn, 1024)
return cn return cn
} }
func (cn *conn) Read(b []byte) (int, error) { func (cn *conn) Read(b []byte) (int, error) {
if cn.readTimeout != 0 { if cn.readTimeout != 0 {
cn.Cn.SetReadDeadline(time.Now().Add(cn.readTimeout)) cn.cn.SetReadDeadline(time.Now().Add(cn.readTimeout))
} else { } 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) { func (cn *conn) Write(b []byte) (int, error) {
if cn.writeTimeout != 0 { if cn.writeTimeout != 0 {
cn.Cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout)) cn.cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout))
} else { } 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 { if p.idleTimeout > 0 {
for e := p.conns.Front(); e != nil; e = e.Next() { for e := p.conns.Front(); e != nil; e = e.Next() {
cn := e.Value.(*conn) cn := e.Value.(*conn)
if time.Since(cn.UsedAt) > p.idleTimeout { if time.Since(cn.usedAt) > p.idleTimeout {
p.conns.Remove(e) p.conns.Remove(e)
} }
} }
@ -115,12 +114,12 @@ func (p *connPool) Get() (*conn, bool, error) {
} }
func (p *connPool) Put(cn *conn) error { func (p *connPool) Put(cn *conn) error {
if cn.Rd.Buffered() != 0 { if cn.rd.Buffered() != 0 {
panic("pool: attempt to put connection with buffered data") panic("redis: attempt to put connection with buffered data")
} }
p.cond.L.Lock() p.cond.L.Lock()
cn.UsedAt = time.Now() cn.usedAt = time.Now()
p.conns.PushFront(cn) p.conns.PushFront(cn)
p.cond.Signal() p.cond.Signal()
p.cond.L.Unlock() p.cond.L.Unlock()
@ -167,7 +166,7 @@ func (p *connPool) Close() error {
} }
func (p *connPool) closeConn(cn *conn) error { func (p *connPool) closeConn(cn *conn) error {
return cn.Cn.Close() return cn.cn.Close()
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -52,7 +52,7 @@ func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error) {
} }
cn.readTimeout = timeout cn.readTimeout = timeout
replyIface, err := NewSliceCmd().parseReply(cn.Rd) replyIface, err := NewSliceCmd().parseReply(cn.rd)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -124,7 +124,7 @@ func (c *baseClient) run(cmd Cmder) {
return return
} }
val, err := cmd.parseReply(cn.Rd) val, err := cmd.parseReply(cn.rd)
if err != nil { if err != nil {
c.freeConn(cn, err) c.freeConn(cn, err)
cmd.setErr(err) cmd.setErr(err)