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.9 kB

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

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.