1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-01 16:06:54 +03:00

Simplify resubscribing in PubSub.

This commit is contained in:
Vladimir Mihailenco
2016-09-29 12:07:04 +00:00
parent 833b0c68df
commit e57ac63b6e
14 changed files with 90 additions and 93 deletions

View File

@ -30,23 +30,23 @@ func (p *StickyConnPool) First() *Conn {
return cn
}
func (p *StickyConnPool) Get() (*Conn, error) {
func (p *StickyConnPool) Get() (*Conn, bool, error) {
defer p.mx.Unlock()
p.mx.Lock()
if p.closed {
return nil, ErrClosed
return nil, false, ErrClosed
}
if p.cn != nil {
return p.cn, nil
return p.cn, false, nil
}
cn, err := p.pool.Get()
cn, _, err := p.pool.Get()
if err != nil {
return nil, err
return nil, false, err
}
p.cn = cn
return cn, nil
return cn, true, nil
}
func (p *StickyConnPool) put() (err error) {