Merge pull request 'updated schedule apis' (#148) from tzwang/pcm-coordinator:master into master
Former-commit-id: 33c256400e9fe429118828ad65d4b561dc948bb9
This commit is contained in:
commit
1b9a73c0a0
|
@ -972,6 +972,9 @@ service pcm {
|
||||||
|
|
||||||
@handler UploadAlgothmCodeHandler
|
@handler UploadAlgothmCodeHandler
|
||||||
post /schedule/getDownloadAlgothmCode (UploadAlgorithmCodeReq) returns (UploadAlgorithmCodeResp)
|
post /schedule/getDownloadAlgothmCode (UploadAlgorithmCodeReq) returns (UploadAlgorithmCodeResp)
|
||||||
|
|
||||||
|
@handler GetComputeCardsByClusterHandler
|
||||||
|
get /schedule/getComputeCardsByCluster/:adapterId/:clusterId (GetComputeCardsByClusterReq) returns (GetComputeCardsByClusterResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@server(
|
@server(
|
||||||
|
|
|
@ -129,4 +129,13 @@ type (
|
||||||
|
|
||||||
UploadAlgorithmCodeResp {
|
UploadAlgorithmCodeResp {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetComputeCardsByClusterReq {
|
||||||
|
AdapterId string `path:"adapterId"`
|
||||||
|
ClusterId string `path:"clusterId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
GetComputeCardsByClusterResp {
|
||||||
|
Cards []string `json:"cards"`
|
||||||
|
}
|
||||||
)
|
)
|
|
@ -1215,6 +1215,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/schedule/getDownloadAlgothmCode",
|
Path: "/schedule/getDownloadAlgothmCode",
|
||||||
Handler: schedule.UploadAlgothmCodeHandler(serverCtx),
|
Handler: schedule.UploadAlgothmCodeHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/schedule/getComputeCardsByCluster/:adapterId/:clusterId",
|
||||||
|
Handler: schedule.GetComputeCardsByClusterHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package schedule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DownloadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.DownloadAlgorithmCodeReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := schedule.NewDownloadAlgothmCodeLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.DownloadAlgothmCode(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package schedule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetComputeCardsByClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.GetComputeCardsByClusterReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := schedule.NewGetComputeCardsByClusterLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetComputeCardsByCluster(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package schedule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UploadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.UploadAlgorithmCodeReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := schedule.NewUploadAlgothmCodeLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.UploadAlgothmCode(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,7 +77,7 @@ func (l *GetCenterTaskListLogic) GetCenterTaskList() (resp *types.CenterTaskList
|
||||||
select {
|
select {
|
||||||
case _ = <-ch:
|
case _ = <-ch:
|
||||||
return resp, nil
|
return resp, nil
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5705,6 +5705,15 @@ type UploadAlgorithmCodeReq struct {
|
||||||
type UploadAlgorithmCodeResp struct {
|
type UploadAlgorithmCodeResp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetComputeCardsByClusterReq struct {
|
||||||
|
AdapterId string `path:"adapterId"`
|
||||||
|
ClusterId string `path:"clusterId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetComputeCardsByClusterResp struct {
|
||||||
|
Cards []string `json:"cards"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreateAlertRuleReq struct {
|
type CreateAlertRuleReq struct {
|
||||||
CLusterId string `json:"clusterId"`
|
CLusterId string `json:"clusterId"`
|
||||||
ClusterName string `json:"clusterName"`
|
ClusterName string `json:"clusterName"`
|
||||||
|
|
Loading…
Reference in New Issue