Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kizuna-lek committed Dec 4, 2024
1 parent caddc86 commit 1bec78d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions engines/redis/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ const (
EnvRootUser = "REDIS_DEFAULT_USER"
EnvRootPasswd = "REDIS_DEFAULT_PASSWORD"

EnvRedisHostNetworkPort = "DBCTL_REDIS_HOST_NETWORK_PORT"
EnvRedisSentinelHostNetworkPort = "DBCTL_REDIS_SENTINEL_HOST_NETWORK_PORT"
EnvRedisClusterHostNetworkPort = "DBCTL_REDIS_CLUSTER_HOST_NETWORK_PORT"
EnvRedisServicePort = "DBCTL_REDIS_SERVICE_PORT"
EnvRedisSentinelServicePort = "DBCTL_REDIS_SENTINEL_SERVICE_PORT"
)

var (
Expand Down Expand Up @@ -78,10 +77,8 @@ func NewManager(properties engines.Properties) (engines.DBManager, error) {
redisPasswd = viper.GetString(EnvRootPasswd)
}

if viper.IsSet(EnvRedisHostNetworkPort) {
properties["redisHost"] = fmt.Sprintf("127.0.0.1:%s", viper.GetString(EnvRedisHostNetworkPort))
} else if viper.IsSet(EnvRedisClusterHostNetworkPort) {
properties["redisHost"] = fmt.Sprintf("127.0.0.1:%s", viper.GetString(EnvRedisClusterHostNetworkPort))
if viper.IsSet(EnvRedisServicePort) {
properties["redisHost"] = fmt.Sprintf("127.0.0.1:%s", viper.GetString(EnvRedisServicePort))
}

managerBase, err := engines.NewDBManagerBase(logger)
Expand Down
4 changes: 2 additions & 2 deletions engines/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ func newClient(s *Settings) redis.UniversalClient {
func newSentinelClient(s *Settings, clusterCompName string) *redis.SentinelClient {
sentinelHost := fmt.Sprintf("%s-sentinel-headless", clusterCompName)
sentinelPort := "26379"
if viper.IsSet(EnvRedisSentinelHostNetworkPort) {
sentinelPort = viper.GetString(EnvRedisSentinelHostNetworkPort)
if viper.IsSet(EnvRedisSentinelServicePort) {
sentinelPort = viper.GetString(EnvRedisSentinelServicePort)
}

opt := &redis.Options{
Expand Down

0 comments on commit 1bec78d

Please sign in to comment.