mirror of
https://github.com/tiny-craft/tiny-rdm.git
synced 2025-05-16 01:58:05 +08:00
fix: close original client after cluster client established
This commit is contained in:
parent
2fb7e06335
commit
10947d777f
@ -150,7 +150,7 @@ func (c *connectionService) buildOption(config types.ConnectionConfig) (*redis.O
|
||||
ReadTimeout: time.Duration(config.ExecTimeout) * time.Second,
|
||||
WriteTimeout: time.Duration(config.ExecTimeout) * time.Second,
|
||||
TLSConfig: tlsConfig,
|
||||
DisableIndentity: true,
|
||||
DisableIdentity: true,
|
||||
IdentitySuffix: "tinyrdm_",
|
||||
}
|
||||
if config.Network == "unix" {
|
||||
@ -238,6 +238,8 @@ func (c *connectionService) createRedisClient(config types.ConnectionConfig) (re
|
||||
|
||||
rdb := redis.NewClient(option)
|
||||
if config.Cluster.Enable {
|
||||
defer rdb.Close()
|
||||
|
||||
// connect to cluster
|
||||
var slots []redis.ClusterSlot
|
||||
if slots, err = rdb.ClusterSlots(c.ctx).Result(); err == nil {
|
||||
@ -265,7 +267,7 @@ func (c *connectionService) createRedisClient(config types.ConnectionConfig) (re
|
||||
ConnMaxIdleTime: option.ConnMaxIdleTime,
|
||||
ConnMaxLifetime: option.ConnMaxLifetime,
|
||||
TLSConfig: option.TLSConfig,
|
||||
DisableIndentity: option.DisableIndentity,
|
||||
DisableIdentity: option.DisableIdentity,
|
||||
}
|
||||
if option.Dialer != nil {
|
||||
clusterOptions.Dialer = option.Dialer
|
||||
|
Loading…
x
Reference in New Issue
Block a user