diff --git a/contrib/nosql/redis/redis.go b/contrib/nosql/redis/redis.go index 6c6204a1f..6be3a2acb 100644 --- a/contrib/nosql/redis/redis.go +++ b/contrib/nosql/redis/redis.go @@ -9,6 +9,7 @@ package redis import ( "context" + "crypto/tls" "time" "github.com/redis/go-redis/v9" @@ -67,7 +68,7 @@ func New(config *gredis.Config) *Redis { redisSentinel := opts.Failover() redisSentinel.ReplicaOnly = config.SlaveOnly client = redis.NewFailoverClient(redisSentinel) - } else if len(opts.Addrs) > 1 { + } else if len(opts.Addrs) > 1 || config.Cluster { client = redis.NewClusterClient(opts.Cluster()) } else { client = redis.NewClient(opts.Simple()) @@ -135,4 +136,9 @@ func fillWithDefaultConfiguration(config *gredis.Config) { if config.ReadTimeout == 0 { config.ReadTimeout = -1 } + if config.TLSConfig == nil && config.TLS { + config.TLSConfig = &tls.Config{ + InsecureSkipVerify: config.TLSSkipVerify, + } + } } diff --git a/database/gredis/gredis_config.go b/database/gredis/gredis_config.go index c743197df..5d804d275 100644 --- a/database/gredis/gredis_config.go +++ b/database/gredis/gredis_config.go @@ -39,6 +39,7 @@ type Config struct { TLSSkipVerify bool `json:"tlsSkipVerify"` // Disables server name verification when connecting over TLS. TLSConfig *tls.Config `json:"-"` // TLS Config to use. When set TLS will be negotiated. SlaveOnly bool `json:"slaveOnly"` // Route all commands to slave read-only nodes. + Cluster bool `json:"cluster"` // Specifies whether cluster mode be used. } const (