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.

nodesloadtoplogic.go 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package monitoring
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type NodesLoadTopLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewNodesLoadTopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NodesLoadTopLogic {
  14. return &NodesLoadTopLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *NodesLoadTopLogic) NodesLoadTop(req *types.NodesLoadTopReq) (resp *types.NodesLoadTopResp, err error) {
  21. resp = &types.NodesLoadTopResp{}
  22. var server string
  23. l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server)
  24. response, err := l.svcCtx.HttpClient.R().
  25. SetQueryParams(map[string]string{
  26. "clusterName": req.ClusterName,
  27. "metrics": req.Metrics,
  28. }).
  29. SetResult(&resp).
  30. ForceContentType("application/json").
  31. Get(server + "/api/v1/monitoring/node")
  32. if err != nil || response.IsError() {
  33. return nil, err
  34. }
  35. return resp, nil
  36. }

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.