mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Add conn health check
This commit is contained in:
@ -310,6 +310,12 @@ func (p *ConnPool) popIdle() *Conn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ConnPool) Put(cn *Conn) {
|
func (p *ConnPool) Put(cn *Conn) {
|
||||||
|
if cn.rd.Buffered() > 0 {
|
||||||
|
internal.Logger.Printf("Conn has unread data")
|
||||||
|
p.Remove(cn, BadConnError{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !cn.pooled {
|
if !cn.pooled {
|
||||||
p.Remove(cn, nil)
|
p.Remove(cn, nil)
|
||||||
return
|
return
|
||||||
|
@ -41,6 +41,10 @@ func NewReader(rd io.Reader) *Reader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Reader) Buffered() int {
|
||||||
|
return r.rd.Buffered()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Reader) Reset(rd io.Reader) {
|
func (r *Reader) Reset(rd io.Reader) {
|
||||||
r.rd.Reset(rd)
|
r.rd.Reset(rd)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user