adapter info
Former-commit-id: c717f0f1d0eabd7121ed7d43a8e22e82603b8d64
This commit is contained in:
parent
8fd635b4a7
commit
2210db4d3c
|
@ -71,3 +71,13 @@ type (
|
|||
failed int `json:"failed"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
adapterInfoReq{
|
||||
clusterId string `form:"clusterId"`
|
||||
}
|
||||
adapterInfoResp{
|
||||
name string `json:"name"`
|
||||
version string `json:"version"`
|
||||
}
|
||||
)
|
|
@ -995,4 +995,7 @@ service pcm {
|
|||
|
||||
@handler taskNumHandler
|
||||
get /monitoring/task/num (taskNumReq) returns (taskNumResp)
|
||||
|
||||
@handler adapterInfoHandler
|
||||
get /monitoring/adapter/info (adapterInfoReq) returns (adapterInfoResp)
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package monitoring
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
)
|
||||
|
||||
func AdapterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterInfoReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := monitoring.NewAdapterInfoLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdapterInfo(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -1252,6 +1252,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/monitoring/task/num",
|
||||
Handler: monitoring.TaskNumHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/monitoring/adapter/info",
|
||||
Handler: monitoring.AdapterInfoHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
)
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package monitoring
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdapterInfoLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdapterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdapterInfoLogic {
|
||||
return &AdapterInfoLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdapterInfoLogic) AdapterInfo(req *types.AdapterInfoReq) (resp *types.AdapterInfoResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
resp = &types.AdapterInfoResp{}
|
||||
l.svcCtx.DbEngin.Raw("select ta.name , ta.version from t_adapter ta,t_cluster tc where tc.id = ? and tc.adapter_id = ta.id", req.ClusterId).Scan(resp)
|
||||
return resp, nil
|
||||
}
|
|
@ -5602,3 +5602,12 @@ type TaskNumResp struct {
|
|||
History int `json:"history"`
|
||||
Failed int `json:"failed"`
|
||||
}
|
||||
|
||||
type AdapterInfoReq struct {
|
||||
ClusterId string `form:"clusterId"`
|
||||
}
|
||||
|
||||
type AdapterInfoResp struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue