package inference import ( "context" "errors" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type DeployInstanceStatLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewDeployInstanceStatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeployInstanceStatLogic { return &DeployInstanceStatLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *DeployInstanceStatLogic) DeployInstanceStat(req *types.DeployInstanceStatReq) (resp *types.DeployInstanceStatResp, err error) { resp = &types.DeployInstanceStatResp{} total, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceTotalNum() if err != nil { return nil, err } running, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceRunningNum() if err != nil { return nil, err } if total == 0 { return nil, errors.New("get statistics failed") } resp.Total = total resp.Running = running return resp, nil }