Skip to content

Commit

Permalink
redis master env
Browse files Browse the repository at this point in the history
  • Loading branch information
Kotodian committed May 5, 2023
1 parent 35f81f8 commit ff4211e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion datasource/go-redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
EnvMaxActiveConns = "REDIS_MAX_ACTIVE_CONNS"
EnvRedisPool = "REDIS_POOL"
EnvReidsAuth = "REDIS_AUTH"
EnvRedisMaster = "REDIS_MASTER"
)

const (
Expand All @@ -36,8 +37,12 @@ func Init() {
return
}
if len(addrs) > 1 {
master := os.Getenv(EnvRedisMaster)
if len(master) == 0 {
master = "mymaster"
}
opts := &redis.FailoverOptions{
MasterName: "mymaster",
MasterName: master,
SentinelAddrs: addrs,
RouteByLatency: true,
}
Expand Down

0 comments on commit ff4211e

Please sign in to comment.