Versions in this module Expand all Collapse all v1 v1.0.1 Jul 6, 2023 v1.0.0 Dec 2, 2022 Changes in this version + const AuthTypeCleartextPassword + const AuthTypeGSS + const AuthTypeGSSCont + const AuthTypeMD5Password + const AuthTypeOk + const AuthTypeSASL + const AuthTypeSASLContinue + const AuthTypeSASLFinal + const AuthTypeSCMCreds + const AuthTypeSSPI + const CONNECTION_WEIGHT + const CPU_WEIGHT + const DISK_IO_WEIGHT + const DefaultMaxConnNum + const Down + const InitConnCount + const MEM_WEIGHT + const ManualDown + const Master + const MaxPoolNum + const PingPeroid + const Slave + const SlaveSplit + const Unknown + const Up + const WeightSplit + func CalculateAndChooseBestNode(cfg *config.NodeConfig, nodeLoad map[int]int) (int, map[int]int, error) + func Gcd(ary []int) int + type BackendConn struct + IsInTransaction bool + func (p *BackendConn) Close() + func (p *BackendConn) CloseForExtendedProtocol() + type Conn struct + ConnPg netpoll.Connection + ConnPgx *pgx.Conn + ProcessID uint32 + SecretKey uint32 + func (c *Conn) Begin() error + func (c *Conn) Close() error + func (c *Conn) ClosePrepare(id uint32) error + func (c *Conn) Commit() error + func (c *Conn) Connect(addr string, user string, password string, db string) error + func (c *Conn) Execute(command string, args ...interface{}) (*mysql.Result, error) + func (c *Conn) FieldList(table string, wildcard string) ([]*mysql.Field, error) + func (c *Conn) GetAddr() string + func (c *Conn) GetCharset() string + func (c *Conn) GetDB() string + func (c *Conn) IsAutoCommit() bool + func (c *Conn) IsInTransaction() bool + func (c *Conn) Ping() error + func (c *Conn) Prepare(query string) (*Stmt, error) + func (c *Conn) ReConnect() error + func (c *Conn) ReConnectPg() error + func (c *Conn) ReadPgAllPacket() ([]byte, error) + func (c *Conn) ReadPgPacket(reader netpoll.Reader) ([]byte, error) + func (c *Conn) Rollback() error + func (c *Conn) SetAutoCommit(n uint8) error + func (c *Conn) SetCharset(charset string, collation mysql.CollationId) error + func (c *Conn) UseDB(dbName string) error + type DB struct + InitConnNum int + func Open(addr string, user string, password string, dbName string, maxConnNum int) (*DB, error) + func (db *DB) Addr() string + func (db *DB) Close() error + func (db *DB) ConnCount() (int, int, int64, int64) + func (db *DB) GetConn() (*BackendConn, error) + func (db *DB) GetConnFromCache(cacheConns chan *Conn) *Conn + func (db *DB) GetConnFromIdle(cacheConns, idleConns chan *Conn) (*Conn, error) + func (db *DB) GetConnPg(dbname string, dbuser string) (*BackendConn, error) + func (db *DB) GetLastPing() int64 + func (db *DB) InitConnPoolPg(dbname string, dbuser string) (cacheConns chan *Conn, err error) + func (db *DB) IsExceedMaxConns() bool + func (db *DB) Ping() error + func (db *DB) PopConn() (*Conn, error) + func (db *DB) PopConnPg(dbname string, dbuser string) (*Conn, error) + func (db *DB) PushConn(co *Conn, err error) + func (db *DB) PushConnForExtendedProtocol(co *Conn, err error) + func (db *DB) SetLastPing() + func (db *DB) State() string + type Data struct + Result []Result + ResultType string + type Metric struct + Device string + Instance string + Job string + type Node struct + BestNodeIndexByMetric int + Cfg config.NodeConfig + DownAfterNoAlive time.Duration + LastSlaveIndex int + Master *DB + NodeCache sync.Map + NodeCacheKey string + NodeLoad map[int]int + NodeLsn sync.Map + Online bool + RoundRobinQ []int + Slave []*DB + SlaveWeights []int + func (n *Node) AddSlave(addr string) error + func (n *Node) CheckConnsCache() + func (n *Node) CheckNode() + func (n *Node) DeleteSlave(addr string) error + func (n *Node) DownMaster(addr string, state int32) error + func (n *Node) DownSlave(addr string, state int32) error + func (n *Node) GetMasterConn() (*BackendConn, error) + func (n *Node) GetMasterConnPg(dbname string, dbuser string) (*BackendConn, error) + func (n *Node) GetNextSlave() (*DB, error) + func (n *Node) GetSlaveConn() (*BackendConn, error) + func (n *Node) GetSlaveConnPg(dbname string, dbuser string, tablename string) (*BackendConn, error) + func (n *Node) InitBalancer() + func (n *Node) OpenDB(addr string) (*DB, error) + func (n *Node) ParseMaster(masterStr string) error + func (n *Node) ParseSlave(slaveStr string) error + func (n *Node) String() string + func (n *Node) UpDB(addr string) (*DB, error) + func (n *Node) UpMaster(addr string) error + func (n *Node) UpSlave(addr string) error + type Prometheus struct + Data Data + Status string + type Result struct + Metric Metric + Value []interface{} + Values []interface{} + type Stmt struct + func (s *Stmt) Close() error + func (s *Stmt) ColumnNum() int + func (s *Stmt) Execute(args ...interface{}) (*mysql.Result, error) + func (s *Stmt) GetId() uint32 + func (s *Stmt) ParamNum() int