You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.go 1.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package jcs
  2. import (
  3. "encoding/json"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "gitlink.org.cn/JointCloud/pcm-openi/common"
  8. )
  9. type JobStatusReportReq struct {
  10. TaskName string `json:"taskName"`
  11. TaskID string `json:"taskID"`
  12. Messages []*ReportMessage `json:"messages"`
  13. }
  14. type ReportMessage struct {
  15. Status bool `json:"status"`
  16. Message string `json:"message"`
  17. ClusterID string `json:"clusterID"`
  18. Output string `json:"output"`
  19. }
  20. func StatusReport(url string, report *JobStatusReportReq) error {
  21. resp := struct {
  22. Code string `json:"code"`
  23. Msg string `json:"msg"`
  24. Data string `json:"data"`
  25. }{}
  26. req := common.GetRestyRequest(common.TIMEOUT)
  27. rp, err := req.
  28. SetHeader("Content-Type", "application/json").
  29. SetBody(report).
  30. SetResult(&resp).
  31. Post(url)
  32. if err != nil {
  33. logx.Errorf("############ Report Status Message Error %s", err.Error())
  34. return err
  35. }
  36. logx.Errorf("############ Report Status Message After Sending %s", string(rp.Body()))
  37. return nil
  38. }
  39. func TempSaveReportToTask(store *database.AiStorage, task *types.TaskModel, report *JobStatusReportReq) error {
  40. jsonBytes, err := json.Marshal(report)
  41. task.Result = string(jsonBytes)
  42. err = store.UpdateTask(task)
  43. if err != nil {
  44. return err
  45. }
  46. return nil
  47. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.