Browse Source

added startall logics

Former-commit-id: 28d49b1a13
pull/278/head
tzwang 1 year ago
parent
commit
7af11688ef
9 changed files with 213 additions and 2 deletions
  1. +2
    -2
      desc/inference/inference.api
  2. +28
    -0
      internal/handler/inference/getdeploytaskshandler.go
  3. +28
    -0
      internal/handler/inference/startallbydeploytaskidhandler.go
  4. +28
    -0
      internal/handler/inference/stopallbydeploytaskidhandler.go
  5. +15
    -0
      internal/handler/routes.go
  6. +30
    -0
      internal/logic/inference/getdeploytaskslogic.go
  7. +30
    -0
      internal/logic/inference/startallbydeploytaskidlogic.go
  8. +30
    -0
      internal/logic/inference/stopallbydeploytaskidlogic.go
  9. +22
    -0
      internal/types/types.go

+ 2
- 2
desc/inference/inference.api View File

@@ -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 {


+ 28
- 0
internal/handler/inference/getdeploytaskshandler.go View File

@@ -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)
}
}
}

+ 28
- 0
internal/handler/inference/startallbydeploytaskidhandler.go View File

@@ -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)
}
}
}

+ 28
- 0
internal/handler/inference/stopallbydeploytaskidhandler.go View File

@@ -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)
}
}
}

+ 15
- 0
internal/handler/routes.go View File

@@ -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"),
)


+ 30
- 0
internal/logic/inference/getdeploytaskslogic.go 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 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
}

+ 30
- 0
internal/logic/inference/startallbydeploytaskidlogic.go 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 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
}

+ 30
- 0
internal/logic/inference/stopallbydeploytaskidlogic.go 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 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
}

+ 22
- 0
internal/types/types.go View File

@@ -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
}

Loading…
Cancel
Save