全局配置有变化时也提示更新集群

This commit is contained in:
刘祥超
2020-11-02 10:44:59 +08:00
parent cdb5dbc4e8
commit 7507a6261b
4 changed files with 25 additions and 2 deletions

View File

@@ -212,8 +212,14 @@ func (this *ServerDAO) UpdateServerConfig(serverId int64, configJSON []byte, upd
return false, err
}
globalConfig, err := SharedSysSettingDAO.ReadSetting(SettingCodeServerGlobalConfig)
if err != nil {
return false, err
}
m := md5.New()
_, _ = m.Write(configJSON)
_, _ = m.Write(configJSON) // 当前服务配置
_, _ = m.Write(globalConfig) // 全局配置
h := m.Sum(nil)
newConfigMd5 := fmt.Sprintf("%x", h)

View File

@@ -801,3 +801,19 @@ func (this *ServerService) CountAllEnabledServersWithGroupId(ctx context.Context
Count: count,
}, nil
}
// 通知更新
func (this *ServerService) NotifyServersChange(ctx context.Context, req *pb.NotifyServersChangeRequest) (*pb.NotifyServersChangeResponse, error) {
// 校验请求
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
if err != nil {
return nil, err
}
err = models.SharedSysEventDAO.CreateEvent(models.NewServerChangeEvent())
if err != nil {
return nil, err
}
return &pb.NotifyServersChangeResponse{}, nil
}

View File

@@ -14,6 +14,7 @@ func init() {
})
}
// 事件相关处理程序
type EventLooper struct {
}