获取应用分发详情修改
Signed-off-by: devad <cossjie@foxmail.com> Former-commit-id: a8959f0e079699fcb40110448315345504ce51a1
This commit is contained in:
parent
1e3518a14e
commit
444e487e87
|
@ -614,4 +614,8 @@ type (
|
||||||
MemoryRate float64 `json:"memoryRate"`
|
MemoryRate float64 `json:"memoryRate"`
|
||||||
MemoryLimit float64 `json:"memoryLimit"`
|
MemoryLimit float64 `json:"memoryLimit"`
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
AppTaskResp {
|
||||||
|
data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
|
@ -531,11 +531,15 @@ service pcm {
|
||||||
@handler AppListHandler
|
@handler AppListHandler
|
||||||
get /apps/list (AppListReq) returns (AppListResp)
|
get /apps/list (AppListReq) returns (AppListResp)
|
||||||
|
|
||||||
@doc "应用详情"
|
@doc "获取应用分发详情"
|
||||||
@handler AppDetailHandler
|
@handler AppDetailHandler
|
||||||
get /apps/detail/:appName (AppDetailReq) returns (AppDetailResp)
|
get /apps/distribute/:appName (AppDetailReq) returns (AppDetailResp)
|
||||||
|
|
||||||
@doc "应用pods列表"
|
@doc "应用pods列表"
|
||||||
@handler AppPodsHandler
|
@handler AppPodsHandler
|
||||||
get /apps/pods/:appName (AppDetailReq) returns (AppDetailResp)
|
get /apps/pods/:appName (AppDetailReq) returns (AppDetailResp)
|
||||||
|
|
||||||
|
@doc "获取应用详情"
|
||||||
|
@handler GetAppByAppName
|
||||||
|
get /apps/getAppByAppName/:appName (AppDetailReq) returns (AppTaskResp)
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package apps
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetAppByAppNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.AppDetailReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
result.ParamErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := apps.NewGetAppByAppNameLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetAppByAppName(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -641,7 +641,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/apps/detail/:appName",
|
Path: "/apps/distribute/:appName",
|
||||||
Handler: apps.AppDetailHandler(serverCtx),
|
Handler: apps.AppDetailHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -649,6 +649,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/apps/pods/:appName",
|
Path: "/apps/pods/:appName",
|
||||||
Handler: apps.AppPodsHandler(serverCtx),
|
Handler: apps.AppPodsHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/apps/getAppByAppName/:appName",
|
||||||
|
Handler: apps.GetAppByAppNameHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package apps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"gorm.io/datatypes"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ type Task struct {
|
||||||
StartTime string `db:"start_time"` // 开始时间
|
StartTime string `db:"start_time"` // 开始时间
|
||||||
EndTime string `db:"end_time"` // 结束运行时间
|
EndTime string `db:"end_time"` // 结束运行时间
|
||||||
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
|
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
|
||||||
YamlString string `db:"yaml_string"`
|
YamlString datatypes.JSON `db:"yaml_string"`
|
||||||
Result string `db:"result"` // 作业结果
|
Result string `db:"result"` // 作业结果
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
NsID string `db:"ns_id"`
|
NsID string `db:"ns_id"`
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package apps
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetAppByAppNameLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetAppByAppNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAppByAppNameLogic {
|
||||||
|
return &GetAppByAppNameLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetAppByAppNameLogic) GetAppByAppName(req *types.AppDetailReq) (resp interface{}, err error) {
|
||||||
|
var task Task
|
||||||
|
db := l.svcCtx.DbEngin.Raw("select * from task where ns_id = ? and name = ?", req.NsID, req.Name).Scan(&task)
|
||||||
|
if db.Error != nil {
|
||||||
|
logx.Errorf("db error: %v", db.Error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp = task.YamlString
|
||||||
|
return
|
||||||
|
}
|
|
@ -578,6 +578,10 @@ type AppDetailResp struct {
|
||||||
MemoryLimit float64 `json:"memoryLimit"`
|
MemoryLimit float64 `json:"memoryLimit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppTaskResp struct {
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
SlurmVersion string `json:"slurmVersion"`
|
SlurmVersion string `json:"slurmVersion"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
Loading…
Reference in New Issue