updated getRunningInstanceByModel api

Former-commit-id: 2d48dac755
This commit is contained in:
tzwang 2024-08-23 17:18:04 +08:00
parent 3f21737673
commit da674642ea
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package inference
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/tzwang/pcm-coordinator/internal/logic/inference"
"gitlink.org.cn/tzwang/pcm-coordinator/internal/svc"
"gitlink.org.cn/tzwang/pcm-coordinator/internal/types"
)
func GetRunningInstanceByModelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetRunningInstanceReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := inference.NewGetRunningInstanceByModelLogic(r.Context(), svcCtx)
resp, err := l.GetRunningInstanceByModel(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -0,0 +1,30 @@
package inference
import (
"context"
"gitlink.org.cn/tzwang/pcm-coordinator/internal/svc"
"gitlink.org.cn/tzwang/pcm-coordinator/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetRunningInstanceByModelLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetRunningInstanceByModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByModelLogic {
return &GetRunningInstanceByModelLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetRunningInstanceByModelLogic) GetRunningInstanceByModel(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
// todo: add your logic here and delete this line
return
}