| @@ -157,7 +157,7 @@ type ( | |||||
| } | } | ||||
| GetRunningInstanceReq { | GetRunningInstanceReq { | ||||
| Id string `json:"deployTaskId"` | |||||
| Id string `form:"deployTaskId"` | |||||
| } | } | ||||
| GetRunningInstanceResp { | GetRunningInstanceResp { | ||||
| List interface{} `json:"list"` | List interface{} `json:"list"` | ||||
| @@ -966,8 +966,8 @@ service pcm { | |||||
| @handler StopAllByDeployTaskId | @handler StopAllByDeployTaskId | ||||
| post /inference/stopAll (StopAllByDeployTaskIdReq) returns (StopAllByDeployTaskIdResp) | post /inference/stopAll (StopAllByDeployTaskIdReq) returns (StopAllByDeployTaskIdResp) | ||||
| @handler GetRunningInstanceByType | |||||
| get /inference/getInstanceByType (GetRunningInstanceReq) returns (GetRunningInstanceResp) | |||||
| @handler GetRunningInstanceById | |||||
| get /inference/getRunningInstanceById (GetRunningInstanceReq) returns (GetRunningInstanceResp) | |||||
| @handler GetDeployTasksByType | @handler GetDeployTasksByType | ||||
| get /inference/getDeployTasksByType (GetDeployTasksByTypeReq) returns (GetDeployTasksByTypeResp) | get /inference/getDeployTasksByType (GetDeployTasksByTypeReq) returns (GetDeployTasksByTypeResp) | ||||
| @@ -1,7 +1,6 @@ | |||||
| package inference | package inference | ||||
| import ( | import ( | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" | |||||
| "net/http" | "net/http" | ||||
| "github.com/zeromicro/go-zero/rest/httpx" | "github.com/zeromicro/go-zero/rest/httpx" | ||||
| @@ -10,17 +9,20 @@ import ( | |||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" | "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) { | return func(w http.ResponseWriter, r *http.Request) { | ||||
| var req types.GetRunningInstanceReq | var req types.GetRunningInstanceReq | ||||
| if err := httpx.Parse(r, &req); err != nil { | if err := httpx.Parse(r, &req); err != nil { | ||||
| result.ParamErrorResult(r, w, err) | |||||
| httpx.ErrorCtx(r.Context(), w, err) | |||||
| return | 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) | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1225,8 +1225,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | |||||
| }, | }, | ||||
| { | { | ||||
| Method: http.MethodGet, | Method: http.MethodGet, | ||||
| Path: "/inference/getInstanceByType", | |||||
| Handler: inference.GetRunningInstanceByTypeHandler(serverCtx), | |||||
| Path: "/inference/getRunningInstanceById", | |||||
| Handler: inference.GetRunningInstanceByIdHandler(serverCtx), | |||||
| }, | }, | ||||
| { | { | ||||
| Method: http.MethodGet, | Method: http.MethodGet, | ||||
| @@ -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 | |||||
| } | |||||
| @@ -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 | |||||
| } | |||||
| @@ -6053,7 +6053,7 @@ type StopAllByDeployTaskIdResp struct { | |||||
| } | } | ||||
| type GetRunningInstanceReq struct { | type GetRunningInstanceReq struct { | ||||
| Id string `json:"deployTaskId"` | |||||
| Id string `form:"deployTaskId"` | |||||
| } | } | ||||
| type GetRunningInstanceResp struct { | type GetRunningInstanceResp struct { | ||||