Browse Source

updated GetRunningInstance apis

Former-commit-id: 8f2ac755f3
pull/289/head
tzwang 1 year ago
parent
commit
9abbf03b33
7 changed files with 45 additions and 43 deletions
  1. +1
    -1
      desc/inference/inference.api
  2. +2
    -2
      desc/pcm.api
  3. +9
    -7
      internal/handler/inference/getrunninginstancebyidhandler.go
  4. +2
    -2
      internal/handler/routes.go
  5. +30
    -0
      internal/logic/inference/getrunninginstancebyidlogic.go
  6. +0
    -30
      internal/logic/inference/getrunninginstancebytypelogic.go
  7. +1
    -1
      internal/types/types.go

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

@@ -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"`


+ 2
- 2
desc/pcm.api View File

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


internal/handler/inference/getrunninginstancebytypehandler.go → internal/handler/inference/getrunninginstancebyidhandler.go View File

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

+ 2
- 2
internal/handler/routes.go View File

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


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

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

+ 1
- 1
internal/types/types.go View File

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


Loading…
Cancel
Save