当服务配置变化时创建单个服务通知任务

This commit is contained in:
刘祥超
2022-01-19 22:15:01 +08:00
parent 5205136809
commit ef045e90f2
16 changed files with 60 additions and 26 deletions

View File

@@ -39,6 +39,7 @@ func (this *NodeTaskService) FindNodeTasks(ctx context.Context, req *pb.FindNode
Type: task.Type,
Version: int64(task.Version),
IsPrimary: primaryNodeId == nodeId,
ServerId: int64(task.ServerId),
})
}
@@ -137,6 +138,7 @@ func (this *NodeTaskService) FindNodeClusterTasks(ctx context.Context, req *pb.F
IsOk: task.IsOk == 1,
Error: task.Error,
UpdatedAt: int64(task.UpdatedAt),
ServerId: int64(task.ServerId),
Node: &pb.Node{
Id: int64(task.NodeId),
Name: nodeName,
@@ -261,6 +263,7 @@ func (this *NodeTaskService) FindNotifyingNodeTasks(ctx context.Context, req *pb
Error: task.Error,
UpdatedAt: int64(task.UpdatedAt),
Node: &pb.Node{Id: int64(task.NodeId)},
ServerId: int64(task.ServerId),
})
}

View File

@@ -1924,3 +1924,29 @@ func (this *ServerService) FindServerUserPlan(ctx context.Context, req *pb.FindS
},
}, nil
}
// ComposeServerConfig 获取服务配置
func (this *ServerService) ComposeServerConfig(ctx context.Context, req *pb.ComposeServerConfigRequest) (*pb.ComposeServerConfigResponse, error) {
_, err := this.ValidateNode(ctx)
if err != nil {
return nil, err
}
var tx = this.NullTx()
serverConfig, err := models.SharedServerDAO.ComposeServerConfigWithServerId(tx, req.ServerId, true)
if err != nil {
if err == models.ErrNotFound {
return &pb.ComposeServerConfigResponse{ServerConfigJSON: nil}, nil
}
return nil, err
}
if serverConfig == nil {
return &pb.ComposeServerConfigResponse{ServerConfigJSON: nil}, nil
}
configJSON, err := json.Marshal(serverConfig)
if err != nil {
return nil, err
}
return &pb.ComposeServerConfigResponse{ServerConfigJSON: configJSON}, nil
}