idbinfo

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

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

func AddBackupDBInfo(dbs map[string][]*DBInfo) error

添加 backup db 信息,map key 为原始 db 的 host:port

func AddBackupDBInfoByJson

func AddBackupDBInfoByJson(backupDBInfoStr string) error

添加 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 AddOriginalDBInfo

func AddOriginalDBInfo(db *DBInfo) error

添加原始 db 信息

func AddOriginalDBInfoByJson

func AddOriginalDBInfoByJson(dbInfoStr string) error

添加原始 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 AddRedisSentinelByJson(sentinelInfoStr string) error

func ClearBackupDB

func ClearBackupDB()

func DestroyDBInfoManager

func DestroyDBInfoManager()

func GetDBInfoManager

func GetDBInfoManager() *dbInfoManager

func InitDBInfoManager

func InitDBInfoManager(option *DBInfoManagerOption) error

func InitDBInfoManagerByConfigFile

func InitDBInfoManagerByConfigFile(configFile string) 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

func GetOneRandomDBInfo(host, port, dbName string) *DBInfo

随机获取一个可用的 db info

func (*DBInfo) GetAddr

func (this *DBInfo) GetAddr() []string

func (*DBInfo) ISmPing

func (this *DBInfo) ISmPing() bool

func (*DBInfo) ISmPingMysql

func (this *DBInfo) ISmPingMysql() bool

func (*DBInfo) ISmPingRedis

func (this *DBInfo) ISmPingRedis() bool

func (*DBInfo) JoinHostPort

func (this *DBInfo) JoinHostPort() string

func (*DBInfo) Ping

func (this *DBInfo) Ping() bool

func (*DBInfo) PingMysql

func (this *DBInfo) PingMysql() bool

func (*DBInfo) PingRedis

func (this *DBInfo) PingRedis() bool

func (*DBInfo) String

func (this *DBInfo) String() string

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL