mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 15:00:26 +08:00
WebP策略变化时只更新相关配置
This commit is contained in:
@@ -100,6 +100,8 @@ func (this *Node) execTask(rpcClient *rpc.RPCClient, task *pb.NodeTask) error {
|
||||
err = this.execTOAChangedTask()
|
||||
case "networkSecurityPolicyChanged":
|
||||
err = this.execNetworkSecurityPolicyChangedTask(rpcClient)
|
||||
case "webPPolicyChanged":
|
||||
err = this.execWebPPolicyChangedTask(rpcClient)
|
||||
default:
|
||||
// 特殊任务
|
||||
if strings.HasPrefix(task.Type, "ipListDeleted") { // 删除IP名单
|
||||
@@ -325,6 +327,34 @@ func (this *Node) execDeleteIPList(taskType string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// WebP策略变更
|
||||
func (this *Node) execWebPPolicyChangedTask(rpcClient *rpc.RPCClient) error {
|
||||
remotelogs.Println("NODE", "updating webp policies ...")
|
||||
resp, err := rpcClient.NodeRPC.FindNodeWebPPolicies(rpcClient.Context(), &pb.FindNodeWebPPoliciesRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var webPPolicyMap = map[int64]*nodeconfigs.WebPImagePolicy{}
|
||||
for _, policy := range resp.WebPPolicies {
|
||||
if len(policy.WebPPolicyJSON) > 0 {
|
||||
var webPPolicy = nodeconfigs.NewWebPImagePolicy()
|
||||
err = json.Unmarshal(policy.WebPPolicyJSON, webPPolicy)
|
||||
if err != nil {
|
||||
remotelogs.Error("NODE", "decode webp policy failed: "+err.Error())
|
||||
continue
|
||||
}
|
||||
err = webPPolicy.Init()
|
||||
if err != nil {
|
||||
remotelogs.Error("NODE", "initialize webp policy failed: "+err.Error())
|
||||
continue
|
||||
}
|
||||
webPPolicyMap[policy.NodeClusterId] = webPPolicy
|
||||
}
|
||||
}
|
||||
sharedNodeConfig.UpdateWebPImagePolicies(webPPolicyMap)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 标记任务完成
|
||||
func (this *Node) finishTask(taskId int64, taskVersion int64, taskErr error) (success bool) {
|
||||
if taskId <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user