diff --git a/internal/handler/inference/getdeployinstancehandler.go b/internal/handler/inference/getdeployinstancehandler.go index 4520c1da..6aa14513 100644 --- a/internal/handler/inference/getdeployinstancehandler.go +++ b/internal/handler/inference/getdeployinstancehandler.go @@ -1,6 +1,7 @@ package inference import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" "github.com/zeromicro/go-zero/rest/httpx" @@ -13,16 +14,13 @@ func GetDeployInstanceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetDeployInstanceReq if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) + result.ParamErrorResult(r, w, err) return } l := inference.NewGetDeployInstanceLogic(r.Context(), svcCtx) resp, err := l.GetDeployInstance(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } + result.HttpResult(r, w, resp, err) + } } diff --git a/internal/logic/inference/getdeployinstancelogic.go b/internal/logic/inference/getdeployinstancelogic.go index 15402403..e084e4c2 100644 --- a/internal/logic/inference/getdeployinstancelogic.go +++ b/internal/logic/inference/getdeployinstancelogic.go @@ -2,6 +2,7 @@ package inference import ( "context" + "strconv" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" @@ -24,7 +25,20 @@ func NewGetDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) } func (l *GetDeployInstanceLogic) GetDeployInstance(req *types.GetDeployInstanceReq) (resp *types.GetDeployInstanceResp, err error) { - // todo: add your logic here and delete this line + resp = &types.GetDeployInstanceResp{} + + id, err := strconv.ParseInt(req.Id, 10, 64) + ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id) + if err != nil { + return nil, err + } + + in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId) + if err != nil { + return nil, err + } + + resp.Instance = in return }