1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Set read/write timeouts more consistently.

This commit is contained in:
Vladimir Mihailenco
2016-12-03 17:30:13 +02:00
parent e7f23a300b
commit b4efc45f1c
18 changed files with 343 additions and 198 deletions

View File

@ -49,7 +49,7 @@ func (p *StickyConnPool) Get() (*Conn, bool, error) {
return cn, true, nil
}
func (p *StickyConnPool) put() (err error) {
func (p *StickyConnPool) putUpstream() (err error) {
err = p.pool.Put(p.cn)
p.cn = nil
return err
@ -67,7 +67,7 @@ func (p *StickyConnPool) Put(cn *Conn) error {
return nil
}
func (p *StickyConnPool) remove(reason error) error {
func (p *StickyConnPool) removeUpstream(reason error) error {
err := p.pool.Remove(p.cn, reason)
p.cn = nil
return err
@ -85,7 +85,7 @@ func (p *StickyConnPool) Remove(cn *Conn, reason error) error {
if cn != nil && p.cn != cn {
panic("p.cn != cn")
}
return p.remove(reason)
return p.removeUpstream(reason)
}
func (p *StickyConnPool) Len() int {
@ -120,10 +120,10 @@ func (p *StickyConnPool) Close() error {
var err error
if p.cn != nil {
if p.reusable {
err = p.put()
err = p.putUpstream()
} else {
reason := errors.New("redis: sticky not reusable connection")
err = p.remove(reason)
reason := errors.New("redis: unreusable sticky connection")
err = p.removeUpstream(reason)
}
}
return err