WebP策略变化时只更新相关配置

This commit is contained in:
GoEdgeLab
2023-12-11 11:08:19 +08:00
parent 7f53748683
commit 9c9cee5537
5 changed files with 51 additions and 9 deletions

View File

@@ -1043,7 +1043,7 @@ func (this *NodeClusterDAO) UpdateClusterWebPPolicy(tx *dbs.Tx, clusterId int64,
return err
}
return this.NotifyUpdate(tx, clusterId)
return this.NotifyWebPPolicyUpdate(tx, clusterId)
}
webpPolicyJSON, err := json.Marshal(webpPolicy)
@@ -1058,7 +1058,7 @@ func (this *NodeClusterDAO) UpdateClusterWebPPolicy(tx *dbs.Tx, clusterId int64,
return err
}
return this.NotifyUpdate(tx, clusterId)
return this.NotifyWebPPolicyUpdate(tx, clusterId)
}
// FindClusterWebPPolicy 查询WebP设置
@@ -1083,7 +1083,7 @@ func (this *NodeClusterDAO) FindClusterWebPPolicy(tx *dbs.Tx, clusterId int64, c
return nodeconfigs.DefaultWebPImagePolicy, nil
}
var policy = &nodeconfigs.WebPImagePolicy{}
var policy = nodeconfigs.NewWebPImagePolicy()
err = json.Unmarshal(webpJSON, policy)
if err != nil {
return nil, err
@@ -1518,6 +1518,11 @@ func (this *NodeClusterDAO) NotifyTOAUpdate(tx *dbs.Tx, clusterId int64) error {
return SharedNodeTaskDAO.CreateClusterTask(tx, nodeconfigs.NodeRoleNode, clusterId, 0, 0, NodeTaskTypeTOAChanged)
}
// NotifyWebPPolicyUpdate 通知WebP策略更新
func (this *NodeClusterDAO) NotifyWebPPolicyUpdate(tx *dbs.Tx, clusterId int64) error {
return SharedNodeTaskDAO.CreateClusterTask(tx, nodeconfigs.NodeRoleNode, clusterId, 0, 0, NodeTaskTypeWebPPolicyChanged)
}
// NotifyDNSUpdate 通知DNS更新
// TODO 更新新的DNS解析记录的同时需要删除老的DNS解析记录
func (this *NodeClusterDAO) NotifyDNSUpdate(tx *dbs.Tx, clusterId int64) error {

View File

@@ -1151,7 +1151,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
// webp
if IsNotNull(nodeCluster.Webp) {
var webpPolicy = &nodeconfigs.WebPImagePolicy{}
var webpPolicy = nodeconfigs.NewWebPImagePolicy()
err = json.Unmarshal(nodeCluster.Webp, webpPolicy)
if err != nil {
return nil, err

View File

@@ -31,6 +31,7 @@ const (
NodeTaskTypeHTTPCCPolicyChanged NodeTaskType = "httpCCPolicyChanged" // CC策略变化
NodeTaskTypeHTTP3PolicyChanged NodeTaskType = "http3PolicyChanged" // HTTP3策略变化
NodeTaskTypeNetworkSecurityPolicyChanged NodeTaskType = "networkSecurityPolicyChanged" // 网络安全策略变化
NodeTaskTypeWebPPolicyChanged NodeTaskType = "webPPolicyChanged" // WebP策略变化
NodeTaskTypeUpdatingServers NodeTaskType = "updatingServers" // 更新一组服务
NodeTaskTypeTOAChanged NodeTaskType = "toaChanged" // TOA配置变化