Documentation
¶
Index ¶
- Constants
- func AddBackupDBInfo(dbs map[string][]*DBInfo) error
- func AddBackupDBInfoByJson(backupDBInfoStr string) error
- func AddOriginalDBInfo(db *DBInfo) error
- func AddOriginalDBInfoByJson(dbInfoStr string) error
- func AddPasswordServer(pwdServer ipassword.PasswordServer) error
- func AddRedisSentinel(sentinelMap map[string][]*RedisSentinelInfo) error
- func AddRedisSentinelByJson(sentinelInfoStr string) error
- func ClearBackupDB()
- func DestroyDBInfoManager()
- func GetDBInfoManager() *dbInfoManager
- func InitDBInfoManager(option *DBInfoManagerOption) error
- func InitDBInfoManagerByConfigFile(configFile string) error
- type DBInfo
- func (this *DBInfo) GetAddr() []string
- func (this *DBInfo) ISmPing() bool
- func (this *DBInfo) ISmPingMysql() bool
- func (this *DBInfo) ISmPingRedis() bool
- func (this *DBInfo) JoinHostPort() string
- func (this *DBInfo) Ping() bool
- func (this *DBInfo) PingMysql() bool
- func (this *DBInfo) PingRedis() bool
- func (this *DBInfo) String() string
- type DBInfoConfig
- type DBInfoManagerOption
- type HostInfoSet
- type RedisSentinelInfo
Constants ¶
View Source
const ( DB_TYPE_MYSQL = "mysql" DB_TYPE_REDIS = "redis" DB_TYPE_REDISCLUSTER = "redis-cluster" )
View Source
const ( DB_UPDATE_METHOD_PING = "ping" DB_UPDATE_METHOD_ISM = "ism" )
Variables ¶
This section is empty.
Functions ¶
func AddBackupDBInfo ¶
添加 backup db 信息,map key 为原始 db 的 host:port
func AddBackupDBInfoByJson ¶
添加 backup db 信息(通过 json string 格式) json string 格式如下:
{
"127.0.0.1:6379":[
{
"host":"127.0.0.2",
"port":"6379",
"password":"test",
"db_type":"redis"
},
{
"host":"127.0.0.3",
"port":"6379",
"password":"test",
"db_type":"redis"
}
]
}
func AddOriginalDBInfoByJson ¶
添加原始 db 信息(通过 json string 格式) json string 格式如下:
{
"host":"127.0.0.1",
"port":"6379",
"password":"test",
"db_type":"redis"
}
func AddPasswordServer ¶
func AddPasswordServer(pwdServer ipassword.PasswordServer) error
func AddRedisSentinel ¶
func AddRedisSentinel(sentinelMap map[string][]*RedisSentinelInfo) error
func AddRedisSentinelByJson ¶
func ClearBackupDB ¶
func ClearBackupDB()
func DestroyDBInfoManager ¶
func DestroyDBInfoManager()
func GetDBInfoManager ¶
func GetDBInfoManager() *dbInfoManager
func InitDBInfoManager ¶
func InitDBInfoManager(option *DBInfoManagerOption) error
Types ¶
type DBInfo ¶
type DBInfo struct {
Host string `json:"host"`
Port string `json:"port"`
UserName string `json:"user_name"`
Password string `json:"password"`
DBName string `json:"db_name"`
DBType string `json:"db_type"`
FlagSsl bool `json:"flag_ssl"`
}
func GetOneRandomDBInfo ¶
随机获取一个可用的 db info
func (*DBInfo) ISmPingMysql ¶
func (*DBInfo) ISmPingRedis ¶
func (*DBInfo) JoinHostPort ¶
type DBInfoConfig ¶
type DBInfoConfig struct {
ManagerOption *DBInfoManagerOption `json:"manager_option"`
BackupDbinfoMap map[string][]*DBInfo `json:"backup_dbinfo_map"`
RedisSentinelMap map[string][]*RedisSentinelInfo `json:"redis_sentinel_map"`
DynamicPwdServer ipassword.PasswordServer `json:"dynamic_pwd_server"`
}
type DBInfoManagerOption ¶
type DBInfoManagerOption struct {
EncryptedPwdFlag bool `json:"encrypted_pwd_flag"`
YinlianDynamicPwdFlag bool `json:"yinlian_dynamic_pwd_flag"`
SwitchDBInfoUpdate bool `json:"switch_db_info_update"`
DBInfoUpdateIntervalSec int `json:"db_info_update_interval_sec"`
DBInfoUpdateMethod string `json:"db_info_update_method"`
}
type HostInfoSet ¶
type HostInfoSet struct {
// contains filtered or unexported fields
}
func (*HostInfoSet) AddDBInfoList ¶
func (this *HostInfoSet) AddDBInfoList(key string, dbList []*DBInfo)
func (*HostInfoSet) Clear ¶
func (this *HostInfoSet) Clear()
func (*HostInfoSet) GetDBInfoList ¶
func (this *HostInfoSet) GetDBInfoList(key string) []*DBInfo
func (*HostInfoSet) ResetDBInfoList ¶
func (this *HostInfoSet) ResetDBInfoList(key string, dbList []*DBInfo)
type RedisSentinelInfo ¶
type RedisSentinelInfo struct {
iredis.RedisSentinelInfo
}
Click to show internal directories.
Click to hide internal directories.