Documentation
¶
Index ¶
- Constants
- func CalculateAndChooseBestNode(cfg *config.NodeConfig, nodeLoad map[int]int) (int, map[int]int, error)
- func Gcd(ary []int) int
- type BackendConn
- type Conn
- 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, parseNode bool) 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(parseNode bool) error
- func (c *Conn) Prepare(query string) (*Stmt, error)
- func (c *Conn) ReConnect() error
- func (c *Conn) ReConnectPg(parseNode bool) 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
- 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(parseNode bool) 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
- type Metric
- type Node
- 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, parseNode bool) (*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
- type Result
- type Stmt
Constants ¶
View Source
const ( AuthTypeOk = 0 AuthTypeCleartextPassword = 3 AuthTypeMD5Password = 5 AuthTypeSCMCreds = 6 AuthTypeGSS = 7 AuthTypeGSSCont = 8 AuthTypeSSPI = 9 AuthTypeSASL = 10 AuthTypeSASLContinue = 11 AuthTypeSASLFinal = 12 )
View Source
const ( Up = iota Down ManualDown Unknown InitConnCount = 16 DefaultMaxConnNum = 1024 PingPeroid int64 = 4 MaxPoolNum = 4 )
View Source
const ( Master = "master" Slave = "slave" SlaveSplit = "," WeightSplit = "@" )
View Source
const ( CPU_WEIGHT = 1 MEM_WEIGHT = 3 DISK_IO_WEIGHT = 3 CONNECTION_WEIGHT = 3 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackendConn ¶
type BackendConn struct { *Conn IsInTransaction bool // 是否在事务中 // contains filtered or unexported fields }
func (*BackendConn) Close ¶
func (p *BackendConn) Close()
func (*BackendConn) CloseForExtendedProtocol ¶
func (p *BackendConn) CloseForExtendedProtocol()
type Conn ¶
type Conn struct { // pg param ConnPg netpoll.Connection ConnPgx *pgx.Conn ProcessID uint32 SecretKey uint32 // contains filtered or unexported fields }
proxy <-> mysql server
func (*Conn) ClosePrepare ¶
func (*Conn) GetCharset ¶
func (*Conn) IsAutoCommit ¶
func (*Conn) IsInTransaction ¶
func (*Conn) ReConnectPg ¶
func (*Conn) ReadPgAllPacket ¶
pg msg streaming can not through this way to get all msg
func (*Conn) SetAutoCommit ¶
func (*Conn) SetCharset ¶
func (c *Conn) SetCharset(charset string, collation mysql.CollationId) error
type DB ¶
func (*DB) GetConn ¶
func (db *DB) GetConn() (*BackendConn, error)
func (*DB) GetConnFromCache ¶
func (*DB) GetConnFromIdle ¶
func (*DB) GetLastPing ¶
func (*DB) InitConnPoolPg ¶
func (*DB) PushConnForExtendedProtocol ¶
func (*DB) SetLastPing ¶
func (db *DB) SetLastPing()
type Node ¶
type Node struct { Cfg config.NodeConfig sync.RWMutex Master *DB Slave []*DB LastSlaveIndex int RoundRobinQ []int SlaveWeights []int DownAfterNoAlive time.Duration Online bool // Select the subscript value of the optimal node through the index BestNodeIndexByMetric int // save node-lsn relationship NodeLsn sync.Map // Node load score NodeLoad map[int]int // save node-cached table relationship NodeCache sync.Map // db_table NodeCacheKey string }
func (*Node) DeleteSlave ¶
func (*Node) GetMasterConn ¶
func (n *Node) GetMasterConn() (*BackendConn, error)
func (*Node) GetMasterConnPg ¶
func (n *Node) GetMasterConnPg(dbname string, dbuser string) (*BackendConn, error)
func (*Node) GetNextSlave ¶
func (*Node) GetSlaveConn ¶
func (n *Node) GetSlaveConn() (*BackendConn, error)
func (*Node) GetSlaveConnPg ¶
func (*Node) InitBalancer ¶
func (n *Node) InitBalancer()
func (*Node) ParseMaster ¶
func (*Node) ParseSlave ¶
slaveStr(127.0.0.1:3306@2,192.168.0.12:3306@3)
type Prometheus ¶
type Result ¶
type Result struct { Metric Metric `json:"metric"` Values []interface{} `json:"values"` Value []interface{} `json:"value"` }
Click to show internal directories.
Click to hide internal directories.