Versions in this module Expand all Collapse all v1 v1.0.0 May 24, 2019 Changes in this version + const DefaultSlice + var DefaultCapacity = 64 + var ErrConnectionPoolClosed = errors.New("connection pool is closed") + type ConnectionPool struct + func NewConnectionPool(addr, user, password, db string, capacity, maxCapacity int, ...) *ConnectionPool + func (cp *ConnectionPool) Active() int64 + func (cp *ConnectionPool) Addr() string + func (cp *ConnectionPool) Available() int64 + func (cp *ConnectionPool) Capacity() int64 + func (cp *ConnectionPool) Close() + func (cp *ConnectionPool) Get(ctx context.Context) (*PooledConnection, error) + func (cp *ConnectionPool) IdleClosed() int64 + func (cp *ConnectionPool) IdleTimeout() time.Duration + func (cp *ConnectionPool) InUse() int64 + func (cp *ConnectionPool) MaxCap() int64 + func (cp *ConnectionPool) Open() + func (cp *ConnectionPool) Put(pc *PooledConnection) + func (cp *ConnectionPool) SetCapacity(capacity int) (err error) + func (cp *ConnectionPool) SetIdleTimeout(idleTimeout time.Duration) + func (cp *ConnectionPool) StatsJSON() string + func (cp *ConnectionPool) WaitCount() int64 + func (cp *ConnectionPool) WaitTime() time.Duration + type DirectConnection struct + func NewDirectConnection(addr string, user string, password string, db string, charset string, ...) (*DirectConnection, error) + func (dc *DirectConnection) Begin() error + func (dc *DirectConnection) Close() + func (dc *DirectConnection) Commit() error + func (dc *DirectConnection) Execute(sql string) (*mysql.Result, error) + func (dc *DirectConnection) FieldList(table string, wildcard string) ([]*mysql.Field, error) + func (dc *DirectConnection) GetAddr() string + func (dc *DirectConnection) GetCharset() string + func (dc *DirectConnection) GetDB() string + func (dc *DirectConnection) IsAutoCommit() bool + func (dc *DirectConnection) IsClosed() bool + func (dc *DirectConnection) IsInTransaction() bool + func (dc *DirectConnection) Ping() error + func (dc *DirectConnection) ResetConnection() error + func (dc *DirectConnection) Rollback() error + func (dc *DirectConnection) SetAutoCommit(v uint8) error + func (dc *DirectConnection) SetCharset(charset string, collation mysql.CollationID) (bool, error) + func (dc *DirectConnection) SetSessionVariables(frontend *mysql.SessionVariables) (bool, error) + func (dc *DirectConnection) UseDB(dbName string) error + func (dc *DirectConnection) WriteSetStatement() error + type PooledConnection struct + func (pc *PooledConnection) Begin() error + func (pc *PooledConnection) Close() + func (pc *PooledConnection) Commit() error + func (pc *PooledConnection) Execute(sql string) (*mysql.Result, error) + func (pc *PooledConnection) FieldList(table string, wildcard string) ([]*mysql.Field, error) + func (pc *PooledConnection) GetAddr() string + func (pc *PooledConnection) IsClosed() bool + func (pc *PooledConnection) Reconnect() error + func (pc *PooledConnection) Recycle() + func (pc *PooledConnection) Rollback() error + func (pc *PooledConnection) SetAutoCommit(v uint8) error + func (pc *PooledConnection) SetCharset(charset string, collation mysql.CollationID) (bool, error) + func (pc *PooledConnection) SetSessionVariables(frontend *mysql.SessionVariables) (bool, error) + func (pc *PooledConnection) UseDB(db string) error + func (pc *PooledConnection) WriteSetStatement() error + type Slice struct + Cfg models.Slice + LastSlaveIndex int + LastStatisticSlaveIndex int + Master *ConnectionPool + RoundRobinQ []int + Slave []*ConnectionPool + SlaveWeights []int + StatisticSlave []*ConnectionPool + StatisticSlaveRoundRobinQ []int + StatisticSlaveWeights []int + func (s *Slice) Close() error + func (s *Slice) GetConn(fromSlave bool, userType int) (pc *PooledConnection, err error) + func (s *Slice) GetMasterConn() (*PooledConnection, error) + func (s *Slice) GetSlaveConn() (*PooledConnection, error) + func (s *Slice) GetSliceName() string + func (s *Slice) GetStatisticSlaveConn() (*PooledConnection, error) + func (s *Slice) ParseMaster(masterStr string) error + func (s *Slice) ParseSlave(slaves []string) error + func (s *Slice) ParseStatisticSlave(statisticSlaves []string) error + func (s *Slice) SetCharsetInfo(charset string, collationID mysql.CollationID)