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 2.0 kB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. TaskName string `json:"taskName"`
  12. TaskID string `json:"taskID"`
  13. Messages []interface{} `json:"messages"`
  14. }
  15. type TrainReportMessage struct {
  16. Type string `json:"type"`
  17. TaskName string `json:"taskName"`
  18. TaskID string `json:"taskID"`
  19. Status bool `json:"status"`
  20. Message string `json:"message"`
  21. ClusterID string `json:"clusterID"`
  22. Output string `json:"output"`
  23. }
  24. type InferReportMessage struct {
  25. Type string `json:"type"`
  26. TaskName string `json:"taskName"`
  27. TaskID string `json:"taskID"`
  28. Status bool `json:"status"`
  29. Message string `json:"message"`
  30. ClusterID string `json:"clusterID"`
  31. Url string `json:"url"`
  32. }
  33. func StatusReport(url string, report interface{}) error {
  34. resp := struct {
  35. Code string `json:"code"`
  36. Msg string `json:"message"`
  37. Data string `json:"data"`
  38. }{}
  39. req := common.GetRestyRequest(common.TIMEOUT)
  40. rp, err := req.
  41. SetHeader("Content-Type", "application/json").
  42. SetBody(report).
  43. SetResult(&resp).
  44. Post(url)
  45. if err != nil {
  46. logx.Errorf("############ Report Status Message Error %s", err.Error())
  47. return err
  48. }
  49. if resp.Code != "OK" {
  50. logx.Errorf("############ Report Status Message After Sending %s", string(rp.Body()))
  51. return fmt.Errorf("report status message failed: %s", resp.Msg)
  52. }
  53. logx.Errorf("############ Report Status Message After Sending %s", string(rp.Body()))
  54. return nil
  55. }
  56. func TempSaveReportToTask(store *database.AiStorage, task *types.TaskModel, report interface{}) error {
  57. jsonBytes, err := json.Marshal(report)
  58. task.Result = string(jsonBytes)
  59. err = store.UpdateTask(task)
  60. if err != nil {
  61. return err
  62. }
  63. return nil
  64. }

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.