redis/internal/pool/pool_single.go

56 lines
859 B
Go
Raw Normal View History

package pool
2019-06-04 14:05:29 +03:00
import "context"
type SingleConnPool struct {
cn *Conn
}
var _ Pooler = (*SingleConnPool)(nil)
func NewSingleConnPool(cn *Conn) *SingleConnPool {
return &SingleConnPool{
cn: cn,
}
}
2019-06-14 16:00:03 +03:00
func (p *SingleConnPool) NewConn(context.Context) (*Conn, error) {
panic("not implemented")
}
func (p *SingleConnPool) CloseConn(*Conn) error {
panic("not implemented")
}
func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error) {
2018-05-28 17:27:24 +03:00
return p.cn, nil
}
2018-05-28 17:27:24 +03:00
func (p *SingleConnPool) Put(cn *Conn) {
if p.cn != cn {
panic("p.cn != cn")
}
}
2018-05-28 17:27:24 +03:00
func (p *SingleConnPool) Remove(cn *Conn) {
if p.cn != cn {
panic("p.cn != cn")
}
}
func (p *SingleConnPool) Len() int {
return 1
}
2018-05-28 17:27:24 +03:00
func (p *SingleConnPool) IdleLen() int {
return 0
}
func (p *SingleConnPool) Stats() *Stats {
return nil
}
func (p *SingleConnPool) Close() error {
return nil
}