|
- package jcs
-
- import (
- "encoding/json"
- "github.com/zeromicro/go-zero/core/logx"
- "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database"
- "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
- "gitlink.org.cn/JointCloud/pcm-openi/common"
- )
-
- type JobStatusReportReq struct {
- TaskName string `json:"taskName"`
- TaskID string `json:"taskID"`
- Messages []*ReportMessage `json:"messages"`
- }
- type ReportMessage struct {
- Status bool `json:"status"`
- Message string `json:"message"`
- ClusterID string `json:"clusterID"`
- Output string `json:"output"`
- }
-
- func StatusReport(url string, report *JobStatusReportReq) error {
- resp := struct {
- Code string `json:"code"`
- Msg string `json:"msg"`
- Data string `json:"data"`
- }{}
-
- req := common.GetRestyRequest(common.TIMEOUT)
- rp, err := req.
- SetHeader("Content-Type", "application/json").
- SetBody(report).
- SetResult(&resp).
- Post(url)
-
- if err != nil {
- logx.Errorf("############ Report Status Message Error %s", err.Error())
-
- return err
- }
-
- logx.Errorf("############ Report Status Message After Sending %s", string(rp.Body()))
-
- return nil
- }
-
- func TempSaveReportToTask(store *database.AiStorage, task *types.TaskModel, report *JobStatusReportReq) error {
- jsonBytes, err := json.Marshal(report)
-
- task.Result = string(jsonBytes)
-
- err = store.UpdateTask(task)
- if err != nil {
- return err
- }
-
- return nil
- }
|