Documentation
¶
Index ¶
- Constants
- Variables
- func IsEnabledFor(l int) bool
- func NewConnector(pCfg *PolarDBXConfig) (driver.Connector, error)
- func ParseLevel(levelStr string) int
- func SetLevel(l int)
- type Address
- type BasicInFoQuery
- type HaManager
- type LeaderTransferInfo
- type Logger
- type MppInfo
- type NodeWithLoadWeight
- type PolarDBXConfig
- type PolarDBXDriver
- type XClusterInfo
- type XClusterNodeBasic
Constants ¶
View Source
const ( LevelSilent = iota LevelError LevelWarn LevelInfo LevelDebug )
View Source
const ILLEGAL_CHARS = `[\\/:*?"<>|\n\r\t]`
Variables ¶
View Source
var ( ErrNoNodeFound = errors.New("communications link failure: no available nodes meet the conditions") ErrInvalidPort = errors.New("invalid port number") ErrClusterMismatch = errors.New("cluster id mismatch") )
Various errors the driver might return. Can change between driver versions.
View Source
var ( ErrInvalidDSNUnescaped = errors.New("invalid DSN: did you forget to escape a param value?") ErrInvalidDSNAddr = errors.New("invalid DSN: network address not terminated (missing closing brace)") ErrInvalidDSNNoSlash = errors.New("invalid DSN: missing the slash separating the database name") )
View Source
var Version = "v1.0.1"
Functions ¶
func IsEnabledFor ¶
func NewConnector ¶
func NewConnector(pCfg *PolarDBXConfig) (driver.Connector, error)
NewConnector returns new driver.Connector.
func ParseLevel ¶
Types ¶
type BasicInFoQuery ¶
type HaManager ¶
type HaManager struct {
// contains filtered or unexported fields
}
func GetManager ¶
func GetManager(pCfg *PolarDBXConfig) (*HaManager, error)
GetManager 根据集群信息获取或创建并返回一个HaManager实例。 如果集群信息中未指定集群ID,将尝试自动探测。 如果指定或自动生成了集群ID,将根据集群信息和系统临时目录路径生成一个JSON文件路径。 此函数还负责设置或更新HaManager实例的属性,如用户、密码。
func (*HaManager) CnHaChecker ¶
func (hm *HaManager) CnHaChecker()
func (*HaManager) DnHaChecker ¶
func (hm *HaManager) DnHaChecker()
type LeaderTransferInfo ¶
type LeaderTransferInfo struct {
// contains filtered or unexported fields
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) ErrorWithStack ¶
type NodeWithLoadWeight ¶
type PolarDBXConfig ¶
type PolarDBXConfig struct {
// Dsn before Slash
User string // Username
Passwd string // Password (requires User)
Net string // Network (e.g. "tcp", "tcp6", "unix". default: "tcp")
Addr string // Address (default: "127.0.0.1:3306" for "tcp" and "/tmp/mysql.sock" for "unix")
Dbname string // Database name
JsonFile string // json file path
// PolarDBX params
ClusterID int64
HaTimeoutMillis int32 // connect timeout for getting node, default: 10000
HaCheckConnectTimeoutMillis int32 // dial timeout for HA mysql connection
HaCheckSocketTimeoutMillis int32 // read timeout for HA mysql connection
HaCheckIntervalMillis int32 // the same as CheckLeaderTransferringIntervalMillis in DN
CheckLeaderTransferringIntervalMillis int32
LeaderTransferringWaitTimeoutMillis int32 // timeout for leader transferring
SmoothSwitchover bool // TODO: to be supported
IgnoreVip bool
RecordJdbcUrl bool
SlaveOnly bool // read write separation, slaveRead
SlaveWeightThreshold int32
ApplyDelayThreshold int32 // second
DirectMode bool
LoadBalanceAlgorithm string
EnableLog bool
EnableProbeLog bool
// PolarDBX params: CN only
ZoneName string
MinZoneNodes int32
BackupZoneName string
InstanceName string
MppRole string
EnableFollowerRead int32
CnGroup string
BackupCnGroup string
// MYSQL params
MysqlParams map[string]string
// PolarDBX param set
PropertiesSet mapset.Set
}
func NewPolarDBXConfig ¶
func NewPolarDBXConfig() *PolarDBXConfig
func ParsePolarDBXDSN ¶
func ParsePolarDBXDSN(dsn string) (pCfg *PolarDBXConfig, err error)
ParsePolarDBXDSN parses the DSN string to polardb-x and mysql Config
func (*PolarDBXConfig) Clone ¶
func (pCfg *PolarDBXConfig) Clone() *PolarDBXConfig
func (*PolarDBXConfig) FormatMYSQLDSN ¶
func (pCfg *PolarDBXConfig) FormatMYSQLDSN(addr string) (string, bool)
func (*PolarDBXConfig) FormatPolarDBXDSN ¶
func (pCfg *PolarDBXConfig) FormatPolarDBXDSN(addr string) string
type PolarDBXDriver ¶
type PolarDBXDriver struct{}
func (PolarDBXDriver) Open ¶
func (d PolarDBXDriver) Open(dsn string) (driver.Conn, error)
Open new Connection. See https://github.com/go-sql-driver/mysql#dsn-data-source-name for how the DSN string is formatted
func (PolarDBXDriver) OpenConnector ¶
func (d PolarDBXDriver) OpenConnector(dsn string) (driver.Connector, error)
OpenConnector implements driver.DriverContext.
type XClusterInfo ¶
type XClusterInfo struct {
LeaderInfo *XClusterNodeBasic
LeaderTransferInfo *LeaderTransferInfo
GlobalPortGap int32
LongConnection *sql.Conn
}
type XClusterNodeBasic ¶
type XClusterNodeBasic struct {
Tag string `json:"tag"`
Connectable bool `json:"connectable"`
Host string `json:"host"`
Port int32 `json:"port"`
PaxosPort int32 `json:"paxos_port"`
Role string `json:"role"`
Peers []*XClusterNodeBasic `json:"peers"`
Version string `json:"version"`
ClusterID int64 `json:"cluster_id"`
UpdateTime string `json:"update_time"`
}
func (*XClusterNodeBasic) Equals ¶
func (n *XClusterNodeBasic) Equals(other *XClusterNodeBasic) bool
func (*XClusterNodeBasic) String ¶
func (x *XClusterNodeBasic) String() string
String returns a string representation of XClusterNodeBasic
Click to show internal directories.
Click to hide internal directories.