cluster.go 1.1 KB
Newer Older
Y
Your Name 已提交
1 2
package entity

Y
Your Name 已提交
3 4
import "strings"

Y
Your Name 已提交
5 6
//Cluster 集群配置
type Cluster struct {
Y
Your Name 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
	ID        int           `json:"id"`
	Name      string        `json:"name"`
	Title     string        `json:"title"`
	Note      string        `json:"note"`
	NodeCount int           `json:"nodeCount"`
	Redis     *ClusterRedis `json:"redis"`
}

//ClusterRedis 集群redis配置
type ClusterRedis struct {
	Mode     string `json:"mode" yaml:"mode"`
	Addrs    string `json:"addrs" yaml:"addrs"`
	DbIndex  int    `json:"dbIndex" yaml:"dbIndex"`
	Masters  string `json:"masters" yaml:"masters"`
	Password string `json:"password" yaml:"password"`
}

//GetMode 获取redis模式
func (c ClusterRedis) GetMode() string {
	return c.Mode
}

//GetAddrs 获取地址
func (c ClusterRedis) GetAddrs() []string {
	return strings.Split(c.Addrs, ",")
}

//GetMasters 或者masters
func (c ClusterRedis) GetMasters() []string {
	return strings.Split(c.Masters, ",")
}

//GetDbIndex 获取所有
func (c ClusterRedis) GetDbIndex() int {
	return c.DbIndex
}

//GetPassword 获取密码
func (c ClusterRedis) GetPassword() string {
	return c.Password
Y
Your Name 已提交
47
}