2018-12-12 23:50:35 +01:00
|
|
|
package pool
|
|
|
|
|
|
|
|
type SingleConnPool struct {
|
2020-04-09 06:35:36 +02:00
|
|
|
cn *Conn
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ Pooler = (*SingleConnPool)(nil)
|
|
|
|
|
2020-04-09 06:35:36 +02:00
|
|
|
func NewSingleConnPool(cn *Conn) *SingleConnPool {
|
|
|
|
return &SingleConnPool{
|
|
|
|
cn: cn,
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *SingleConnPool) NewConn() (*Conn, error) {
|
2020-04-09 06:35:36 +02:00
|
|
|
panic("not implemented")
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
|
2020-04-09 06:35:36 +02:00
|
|
|
func (p *SingleConnPool) CloseConn(*Conn) error {
|
|
|
|
panic("not implemented")
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *SingleConnPool) Get() (*Conn, error) {
|
2020-04-09 06:35:36 +02:00
|
|
|
return p.cn, nil
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *SingleConnPool) Put(cn *Conn) {
|
2020-04-09 06:35:36 +02:00
|
|
|
if p.cn != cn {
|
|
|
|
panic("p.cn != cn")
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-09 06:35:36 +02:00
|
|
|
func (p *SingleConnPool) Remove(cn *Conn) {
|
|
|
|
if p.cn != cn {
|
|
|
|
panic("p.cn != cn")
|
|
|
|
}
|
2020-04-07 14:31:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-12 23:50:35 +01:00
|
|
|
func (p *SingleConnPool) Len() int {
|
2020-04-09 06:35:36 +02:00
|
|
|
return 1
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *SingleConnPool) IdleLen() int {
|
2020-04-09 06:35:36 +02:00
|
|
|
return 0
|
2018-12-12 23:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *SingleConnPool) Stats() *Stats {
|
2020-04-07 14:31:33 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-04-09 06:35:36 +02:00
|
|
|
func (p *SingleConnPool) Close() error {
|
2018-12-12 23:50:35 +01:00
|
|
|
return nil
|
|
|
|
}
|