pcm-coordinator/internal/logic/inference/inferencetaskstatlogic.go

42 lines
982 B
Go

package inference
import (
"context"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type InferenceTaskStatLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewInferenceTaskStatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InferenceTaskStatLogic {
return &InferenceTaskStatLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *InferenceTaskStatLogic) InferenceTaskStat(req *types.InferenceTaskStatReq) (resp *types.InferenceTaskStatResp, err error) {
resp = &types.InferenceTaskStatResp{}
total, err := l.svcCtx.Scheduler.AiStorages.GetInferenceTaskTotalNum()
if err != nil {
return nil, err
}
running, err := l.svcCtx.Scheduler.AiStorages.GetInferenceTaskRunningNum()
if err != nil {
return nil, err
}
resp.Total = total
resp.Running = running
return resp, nil
}