Skip to content

Commit

Permalink
fix: 修复redis配置单个地址会报错 (#380)
Browse files Browse the repository at this point in the history
修复redis配置单个地址会报错
  • Loading branch information
ywanbing committed Aug 30, 2022
1 parent fa9b38f commit 43a5188
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/client/redis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
)

const (
//ClusterMode using clusterClient
// ClusterMode using clusterClient
ClusterMode string = "cluster"
//StubMode using reidsClient
// StubMode using reidsClient
StubMode string = "stub"
)

Expand Down Expand Up @@ -112,7 +112,12 @@ func RawRedisConfig(key string) Config {
func (config Config) Build() *Redis {
count := len(config.Addrs)
if count < 1 {
config.logger.Panic("no address in redis config", xlog.Any("config", config))
if config.Addr == "" {
config.logger.Panic("no address in redis config", xlog.Any("config", config))
}

// 兼容单个地址
config.Addrs = append(config.Addrs, config.Addr)
}
if len(config.Mode) == 0 {
config.Mode = StubMode
Expand Down

0 comments on commit 43a5188

Please sign in to comment.