diff --git a/desc/inference/inference.api b/desc/inference/inference.api index a0b17940..7379c9a0 100644 --- a/desc/inference/inference.api +++ b/desc/inference/inference.api @@ -122,7 +122,7 @@ type ( } StartAllByDeployTaskIdReq { - Id string `form:"id"` + Id string `form:"deployTaskid"` } StartAllByDeployTaskIdResp { @@ -130,7 +130,7 @@ type ( } StopAllByDeployTaskIdReq { - Id string `form:"id"` + Id string `form:"deployTaskid"` } StopAllByDeployTaskIdResp { diff --git a/internal/handler/inference/getdeploytaskshandler.go b/internal/handler/inference/getdeploytaskshandler.go new file mode 100644 index 00000000..ef6aeeea --- /dev/null +++ b/internal/handler/inference/getdeploytaskshandler.go @@ -0,0 +1,28 @@ +package inference + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetDeployTasksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetDeployTasksReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := inference.NewGetDeployTasksLogic(r.Context(), svcCtx) + resp, err := l.GetDeployTasks(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/inference/startallbydeploytaskidhandler.go b/internal/handler/inference/startallbydeploytaskidhandler.go new file mode 100644 index 00000000..49cd0f7a --- /dev/null +++ b/internal/handler/inference/startallbydeploytaskidhandler.go @@ -0,0 +1,28 @@ +package inference + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func StartAllByDeployTaskIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StartAllByDeployTaskIdReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := inference.NewStartAllByDeployTaskIdLogic(r.Context(), svcCtx) + resp, err := l.StartAllByDeployTaskId(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/inference/stopallbydeploytaskidhandler.go b/internal/handler/inference/stopallbydeploytaskidhandler.go new file mode 100644 index 00000000..edaad256 --- /dev/null +++ b/internal/handler/inference/stopallbydeploytaskidhandler.go @@ -0,0 +1,28 @@ +package inference + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func StopAllByDeployTaskIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StopAllByDeployTaskIdReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := inference.NewStopAllByDeployTaskIdLogic(r.Context(), svcCtx) + resp, err := l.StopAllByDeployTaskId(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 8144516f..0d45957e 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -1213,6 +1213,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/inference/taskStat", Handler: inference.InferenceTaskStatHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/inference/startAll", + Handler: inference.StartAllByDeployTaskIdHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/inference/stopAll", + Handler: inference.StopAllByDeployTaskIdHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/inference/getDeployTasks", + Handler: inference.GetDeployTasksHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/internal/logic/inference/getdeploytaskslogic.go b/internal/logic/inference/getdeploytaskslogic.go new file mode 100644 index 00000000..1f545613 --- /dev/null +++ b/internal/logic/inference/getdeploytaskslogic.go @@ -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 GetDeployTasksLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetDeployTasksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDeployTasksLogic { + return &GetDeployTasksLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetDeployTasksLogic) GetDeployTasks(req *types.GetDeployTasksReq) (resp *types.GetDeployTasksResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/inference/startallbydeploytaskidlogic.go b/internal/logic/inference/startallbydeploytaskidlogic.go new file mode 100644 index 00000000..34d3891b --- /dev/null +++ b/internal/logic/inference/startallbydeploytaskidlogic.go @@ -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 StartAllByDeployTaskIdLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewStartAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartAllByDeployTaskIdLogic { + return &StartAllByDeployTaskIdLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *StartAllByDeployTaskIdLogic) StartAllByDeployTaskId(req *types.StartAllByDeployTaskIdReq) (resp *types.StartAllByDeployTaskIdResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/inference/stopallbydeploytaskidlogic.go b/internal/logic/inference/stopallbydeploytaskidlogic.go new file mode 100644 index 00000000..d1595138 --- /dev/null +++ b/internal/logic/inference/stopallbydeploytaskidlogic.go @@ -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 StopAllByDeployTaskIdLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewStopAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopAllByDeployTaskIdLogic { + return &StopAllByDeployTaskIdLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *StopAllByDeployTaskIdLogic) StopAllByDeployTaskId(req *types.StopAllByDeployTaskIdReq) (resp *types.StopAllByDeployTaskIdResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/types/types.go b/internal/types/types.go index ee08925b..48991b36 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -6012,3 +6012,25 @@ type InferenceTaskStatResp struct { Running int32 `json:"running"` Total int32 `json:"total"` } + +type StartAllByDeployTaskIdReq struct { + Id string `form:"deployTaskid"` +} + +type StartAllByDeployTaskIdResp struct { +} + +type StopAllByDeployTaskIdReq struct { + Id string `form:"deployTaskid"` +} + +type StopAllByDeployTaskIdResp struct { +} + +type GetDeployTasksReq struct { + PageInfo +} + +type GetDeployTasksResp struct { + PageResult +}