func (cp *ConnectionPool) tryReuse(pc *PooledConnection) error {
	return pc.directConnection.ResetConnection()
}
tryReuse reset params of connection before reuse
package backend
import (
	"context"
	"errors"
	"sync"
	"time"
	"github.com/nooncall/shazam/mysql"
	"github.com/nooncall/shazam/util"
)
const (
	getConnTimeout = 2 * time.Second
)
var (
	ErrConnectionPoolClosed = errors.New("connection pool is closed")
	DefaultCapacity = 64
)
type ConnectionPool struct {
	mu          sync.RWMutex
	connections *util.ResourcePool
	addr     string
	user     string
	password string
	db       string
	charset     string
	collationID mysql.CollationID
	capacity    int  
	maxCapacity int  
	idleTimeout time.Duration
}
func NewConnectionPool(addr, user, password, db string, capacity, maxCapacity int, idleTimeout time.Duration, charset string, collationID mysql.CollationID) *ConnectionPool {
	cp := &ConnectionPool{addr: addr, user: user, password: password, db: db, capacity: capacity, maxCapacity: maxCapacity, idleTimeout: idleTimeout, charset: charset, collationID: collationID}
	return cp
}
func (cp *ConnectionPool) pool() (p *util.ResourcePool) {
	cp.mu.Lock()
	p = cp.connections
	cp.mu.Unlock()
	return p
}
func (cp *ConnectionPool) Open() {
	if cp.capacity == 0 {
		cp.capacity = DefaultCapacity
	}
	if cp.maxCapacity == 0 {
		cp.maxCapacity = cp.capacity
	}
	cp.mu.Lock()
	defer cp.mu.Unlock()
	cp.connections = util.NewResourcePool(cp.connect, cp.capacity, cp.maxCapacity, cp.idleTimeout)
	return
}
func (cp *ConnectionPool) connect() (util.Resource, error) {
	c, err := NewDirectConnection(cp.addr, cp.user, cp.password, cp.db, cp.charset, cp.collationID)
	if err != nil {
		return nil, err
	}
	return &PooledConnection{directConnection: c, pool: cp}, nil
}
func (cp *ConnectionPool) Addr() string {
	return cp.addr
}
func (cp *ConnectionPool) Close() {
	p := cp.pool()
	if p == nil {
		return
	}
	p.Close()
	cp.mu.Lock()
	cp.connections = nil
	cp.mu.Unlock()
	return
}