updated GetRunningInstance apis

Former-commit-id: 8f2ac755f354e759d4a3b6a1c981f027045b8da1
This commit is contained in:
tzwang 2024-08-27 15:55:18 +08:00
parent 8ab67fe868
commit 9abbf03b33
7 changed files with 45 additions and 43 deletions

View File

@ -157,7 +157,7 @@ type (
}
GetRunningInstanceReq {
Id string `json:"deployTaskId"`
Id string `form:"deployTaskId"`
}
GetRunningInstanceResp {
List interface{} `json:"list"`

View File

@ -966,8 +966,8 @@ service pcm {
@handler StopAllByDeployTaskId
post /inference/stopAll (StopAllByDeployTaskIdReq) returns (StopAllByDeployTaskIdResp)
@handler GetRunningInstanceByType
get /inference/getInstanceByType (GetRunningInstanceReq) returns (GetRunningInstanceResp)
@handler GetRunningInstanceById
get /inference/getRunningInstanceById (GetRunningInstanceReq) returns (GetRunningInstanceResp)
@handler GetDeployTasksByType
get /inference/getDeployTasksByType (GetDeployTasksByTypeReq) returns (GetDeployTasksByTypeResp)

View File

@ -1,7 +1,6 @@
package inference
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
@ -10,17 +9,20 @@ import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
)
func GetRunningInstanceByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func GetRunningInstanceByIdHandler(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 {
result.ParamErrorResult(r, w, err)
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := inference.NewGetRunningInstanceByTypeLogic(r.Context(), svcCtx)
resp, err := l.GetRunningInstanceByType(&req)
result.HttpResult(r, w, resp, err)
l := inference.NewGetRunningInstanceByIdLogic(r.Context(), svcCtx)
resp, err := l.GetRunningInstanceById(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -1225,8 +1225,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
{
Method: http.MethodGet,
Path: "/inference/getInstanceByType",
Handler: inference.GetRunningInstanceByTypeHandler(serverCtx),
Path: "/inference/getRunningInstanceById",
Handler: inference.GetRunningInstanceByIdHandler(serverCtx),
},
{
Method: http.MethodGet,

View File

@ -0,0 +1,30 @@
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 GetRunningInstanceByIdLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetRunningInstanceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByIdLogic {
return &GetRunningInstanceByIdLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetRunningInstanceByIdLogic) GetRunningInstanceById(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@ -1,30 +0,0 @@
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 GetRunningInstanceByTypeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetRunningInstanceByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByTypeLogic {
return &GetRunningInstanceByTypeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetRunningInstanceByTypeLogic) GetRunningInstanceByType(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
resp = &types.GetRunningInstanceResp{}
return
}

View File

@ -6053,7 +6053,7 @@ type StopAllByDeployTaskIdResp struct {
}
type GetRunningInstanceReq struct {
Id string `json:"deployTaskId"`
Id string `form:"deployTaskId"`
}
type GetRunningInstanceResp struct {