本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
807B

  1. package pool
  2. type SingleConnPool struct {
  3. cn *Conn
  4. }
  5. var _ Pooler = (*SingleConnPool)(nil)
  6. func NewSingleConnPool(cn *Conn) *SingleConnPool {
  7. return &SingleConnPool{
  8. cn: cn,
  9. }
  10. }
  11. func (p *SingleConnPool) NewConn() (*Conn, error) {
  12. panic("not implemented")
  13. }
  14. func (p *SingleConnPool) CloseConn(*Conn) error {
  15. panic("not implemented")
  16. }
  17. func (p *SingleConnPool) Get() (*Conn, error) {
  18. return p.cn, nil
  19. }
  20. func (p *SingleConnPool) Put(cn *Conn) {
  21. if p.cn != cn {
  22. panic("p.cn != cn")
  23. }
  24. }
  25. func (p *SingleConnPool) Remove(cn *Conn) {
  26. if p.cn != cn {
  27. panic("p.cn != cn")
  28. }
  29. }
  30. func (p *SingleConnPool) Len() int {
  31. return 1
  32. }
  33. func (p *SingleConnPool) IdleLen() int {
  34. return 0
  35. }
  36. func (p *SingleConnPool) Stats() *Stats {
  37. return nil
  38. }
  39. func (p *SingleConnPool) Close() error {
  40. return nil
  41. }
上海开阖软件有限公司 沪ICP备12045867号-1