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.

submitlinktasklogic.go 1.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package storelink
  2. import (
  3. "context"
  4. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
  5. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  6. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  7. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type SubmitLinkTaskLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitLinkTaskLogic {
  16. return &SubmitLinkTaskLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) {
  23. participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin)
  24. if *participant == (models.StorelinkCenter{}) {
  25. resp = &types.SubmitLinkTaskResp{}
  26. resp.Success = false
  27. resp.TaskId = ""
  28. resp.ErrorMsg = "partId不存在"
  29. return resp, nil
  30. }
  31. storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant)
  32. var params []string
  33. if len(req.Params) != 0 {
  34. for _, v := range req.Params {
  35. param := v.Key + storeLink.COMMA + v.Val
  36. params = append(params, param)
  37. }
  38. }
  39. var envs []string
  40. if len(req.Envs) != 0 {
  41. for _, v := range req.Envs {
  42. env := v.Key + storeLink.COMMA + v.Val
  43. envs = append(envs, env)
  44. }
  45. }
  46. task, err := storelink.ILinkage.SubmitTask(req.ImageId, req.Cmd, envs, params, req.ResourceId)
  47. if err != nil {
  48. return nil, err
  49. }
  50. taskResp := task.(types.SubmitLinkTaskResp)
  51. return &taskResp, nil
  52. }

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.