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.

tasknumlogic.go 1.2 kB

123456789101112131415161718192021222324252627282930313233
  1. package monitoring
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type TaskNumLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewTaskNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskNumLogic {
  14. return &TaskNumLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *TaskNumLogic) TaskNum(req *types.TaskNumReq) (resp *types.TaskNumResp, err error) {
  21. resp = &types.TaskNumResp{}
  22. l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ? and status = 'running'", req.ClusterId).Scan(resp.Current)
  23. l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = '' and DATE(start_time) = CURDATE()", req.ClusterId).Scan(resp.Today)
  24. l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ?", req.ClusterId).Scan(resp.History)
  25. l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ? and status = 'failed'", req.ClusterId).Scan(resp.Failed)
  26. return resp, nil
  27. }

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.