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