mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-28 14:42:14 +08:00
fix: config
This commit is contained in:
parent
a8a0159534
commit
a78a1d7de4
@ -169,19 +169,18 @@ func compareAndSave[T any](c *gin.Context, old any, req *apistruct.SetConfigReq,
|
|||||||
|
|
||||||
func (cm *ConfigManager) ResetConfig(c *gin.Context) {
|
func (cm *ConfigManager) ResetConfig(c *gin.Context) {
|
||||||
go func() {
|
go func() {
|
||||||
if err := cm.resetConfig(c); err != nil {
|
if err := cm.resetConfig(c, true); err != nil {
|
||||||
log.ZError(c, "reset config err", err)
|
log.ZError(c, "reset config err", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
apiresp.GinSuccess(c, nil)
|
apiresp.GinSuccess(c, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConfigManager) resetConfig(c *gin.Context, ops ...clientv3.Op) error {
|
func (cm *ConfigManager) resetConfig(c *gin.Context, checkChange bool, ops ...clientv3.Op) error {
|
||||||
txn := cm.client.Txn(c)
|
txn := cm.client.Txn(c)
|
||||||
type initConf struct {
|
type initConf struct {
|
||||||
old any
|
old any
|
||||||
new any
|
new any
|
||||||
isChanged bool
|
|
||||||
}
|
}
|
||||||
configMap := map[string]*initConf{
|
configMap := map[string]*initConf{
|
||||||
cm.config.Discovery.GetConfigFileName(): {old: &cm.config.Discovery, new: new(config.Discovery)},
|
cm.config.Discovery.GetConfigFileName(): {old: &cm.config.Discovery, new: new(config.Discovery)},
|
||||||
@ -221,8 +220,8 @@ func (cm *ConfigManager) resetConfig(c *gin.Context, ops ...clientv3.Op) error {
|
|||||||
log.ZError(c, "load config failed", err)
|
log.ZError(c, "load config failed", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
v.isChanged = reflect.DeepEqual(v.old, v.new)
|
equal := reflect.DeepEqual(v.old, v.new)
|
||||||
if !v.isChanged {
|
if !checkChange || !equal {
|
||||||
changedKeys = append(changedKeys, k)
|
changedKeys = append(changedKeys, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +278,7 @@ func (cm *ConfigManager) SetEnableConfigManager(c *gin.Context) {
|
|||||||
if !(resp.Count > 0 && string(resp.Kvs[0].Value) == etcd.Enable) && req.Enable {
|
if !(resp.Count > 0 && string(resp.Kvs[0].Value) == etcd.Enable) && req.Enable {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(waitHttp) // wait for Restart http call return
|
time.Sleep(waitHttp) // wait for Restart http call return
|
||||||
err := cm.resetConfig(c, clientv3.OpPut(etcd.BuildKey(etcd.EnableConfigCenterKey), enableStr))
|
err := cm.resetConfig(c, false, clientv3.OpPut(etcd.BuildKey(etcd.EnableConfigCenterKey), enableStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "resetConfig failed", err)
|
log.ZError(c, "resetConfig failed", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user