未验证 提交 9f4d1a1e 编写于 作者: Z zhousbo 提交者: GitHub

fix: support redis sentinel password (#1315)

上级 ed06da90
......@@ -132,6 +132,8 @@ Address = "127.0.0.1:6379"
RedisType = "standalone"
# Mastername for sentinel type
# MasterName = "mymaster"
# SentinelUsername = ""
# SentinelPassword = ""
[DB]
# postgres: host=%s port=%s user=%s dbname=%s password=%s sslmode=%s
......
......@@ -230,6 +230,8 @@ Address = "127.0.0.1:6379"
RedisType = "standalone"
# Mastername for sentinel type
# MasterName = "mymaster"
# SentinelUsername = ""
# SentinelPassword = ""
[DB]
DSN="root:1234@tcp(127.0.0.1:3306)/n9e_v5?charset=utf8mb4&parseTime=True&loc=Local&allowNativePasswords=true"
......
......@@ -20,8 +20,10 @@ type RedisConfig struct {
DB int
UseTLS bool
tls.ClientConfig
RedisType string
MasterName string
RedisType string
MasterName string
SentinelUsername string
SentinelPassword string
}
var DB *gorm.DB
......@@ -87,11 +89,13 @@ func InitRedis(cfg RedisConfig) (func(), error) {
case "sentinel":
redisOptions := &redis.FailoverOptions{
MasterName: cfg.MasterName,
SentinelAddrs: strings.Split(cfg.Address, ","),
Username: cfg.Username,
Password: cfg.Password,
DB: cfg.DB,
MasterName: cfg.MasterName,
SentinelAddrs: strings.Split(cfg.Address, ","),
Username: cfg.Username,
Password: cfg.Password,
DB: cfg.DB,
SentinelUsername: cfg.SentinelUsername,
SentinelPassword: cfg.SentinelPassword,
}
if cfg.UseTLS {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册