Allow redis to support cluster mode (#633)

This commit is contained in:
SianLoong
2021-09-20 19:53:42 +08:00
committed by GitHub
parent 61af86605e
commit 47222086ac
5 changed files with 89 additions and 48 deletions

View File

@@ -96,7 +96,8 @@ log:
stat:
engine: "memory" # support memory, redis, boltdb, buntdb or leveldb
redis:
addr: "localhost:6379"
cluster: false
addr: "localhost:6379" # if cluster is true, you may set this to "localhost:6379,localhost:6380,localhost:6381"
password: ""
db: 0
boltdb:
@@ -236,6 +237,7 @@ type SectionNATS struct {
// SectionRedis is sub section of config.
type SectionRedis struct {
Cluster bool `yaml:"cluster"`
Addr string `yaml:"addr"`
Password string `yaml:"password"`
DB int `yaml:"db"`
@@ -385,6 +387,7 @@ func LoadConf(confPath ...string) (*ConfYaml, error) {
// Stat Engine
conf.Stat.Engine = viper.GetString("stat.engine")
conf.Stat.Redis.Cluster = viper.GetBool("stat.redis.cluster")
conf.Stat.Redis.Addr = viper.GetString("stat.redis.addr")
conf.Stat.Redis.Password = viper.GetString("stat.redis.password")
conf.Stat.Redis.DB = viper.GetInt("stat.redis.db")