mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 09:20:25 +08:00
规范API命名
This commit is contained in:
@@ -66,7 +66,7 @@ func (this *SyncAPINodesTask) Loop() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newEndpoints := []string{}
|
newEndpoints := []string{}
|
||||||
for _, node := range resp.Nodes {
|
for _, node := range resp.ApiNodes {
|
||||||
if !node.IsOn {
|
if !node.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ func (this *DeleteAction) RunPost(params struct {
|
|||||||
defer this.CreateLog(oplogs.LevelInfo, "删除API节点 %d", params.NodeId)
|
defer this.CreateLog(oplogs.LevelInfo, "删除API节点 %d", params.NodeId)
|
||||||
|
|
||||||
// 检查是否是唯一的节点
|
// 检查是否是唯一的节点
|
||||||
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{NodeId: params.NodeId})
|
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{ApiNodeId: params.NodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var apiNode = nodeResp.Node
|
var apiNode = nodeResp.ApiNode
|
||||||
if apiNode == nil {
|
if apiNode == nil {
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ func (this *DeleteAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = this.RPC().APINodeRPC().DeleteAPINode(this.AdminContext(), &pb.DeleteAPINodeRequest{NodeId: params.NodeId})
|
_, err = this.RPC().APINodeRPC().DeleteAPINode(this.AdminContext(), &pb.DeleteAPINodeRequest{ApiNodeId: params.NodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, node := range nodesResp.Nodes {
|
for _, node := range nodesResp.ApiNodes {
|
||||||
// 状态
|
// 状态
|
||||||
status := &nodeconfigs.NodeStatus{}
|
status := &nodeconfigs.NodeStatus{}
|
||||||
if len(node.StatusJSON) > 0 {
|
if len(node.StatusJSON) > 0 {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建日志
|
// 创建日志
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "创建API节点 %d", createResp.NodeId)
|
defer this.CreateLog(oplogs.LevelInfo, "创建API节点 %d", createResp.ApiNodeId)
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ func (this *IndexAction) Init() {
|
|||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
NodeId int64
|
NodeId int64
|
||||||
}) {
|
}) {
|
||||||
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{NodeId: params.NodeId})
|
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{ApiNodeId: params.NodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
node := nodeResp.Node
|
node := nodeResp.ApiNode
|
||||||
if node == nil {
|
if node == nil {
|
||||||
this.NotFound("apiNode", params.NodeId)
|
this.NotFound("apiNode", params.NodeId)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ func (this *InstallAction) RunGet(params struct {
|
|||||||
NodeId int64
|
NodeId int64
|
||||||
}) {
|
}) {
|
||||||
// API节点信息
|
// API节点信息
|
||||||
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{NodeId: params.NodeId})
|
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{ApiNodeId: params.NodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
node := nodeResp.Node
|
node := nodeResp.ApiNode
|
||||||
if node == nil {
|
if node == nil {
|
||||||
this.NotFound("apiNode", params.NodeId)
|
this.NotFound("apiNode", params.NodeId)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ func (this *LogsAction) RunGet(params struct {
|
|||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
this.Data["level"] = params.Level
|
this.Data["level"] = params.Level
|
||||||
|
|
||||||
apiNodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{NodeId: params.NodeId})
|
apiNodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{ApiNodeId: params.NodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNode := apiNodeResp.Node
|
apiNode := apiNodeResp.ApiNode
|
||||||
if apiNode == nil {
|
if apiNode == nil {
|
||||||
this.NotFound("apiNode", params.NodeId)
|
this.NotFound("apiNode", params.NodeId)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
NodeId int64
|
NodeId int64
|
||||||
}) {
|
}) {
|
||||||
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{
|
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{
|
||||||
NodeId: params.NodeId,
|
ApiNodeId: params.NodeId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
node := nodeResp.Node
|
node := nodeResp.ApiNode
|
||||||
if node == nil {
|
if node == nil {
|
||||||
this.WriteString("要操作的节点不存在")
|
this.WriteString("要操作的节点不存在")
|
||||||
return
|
return
|
||||||
@@ -281,7 +281,7 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err = this.RPC().APINodeRPC().UpdateAPINode(this.AdminContext(), &pb.UpdateAPINodeRequest{
|
_, err = this.RPC().APINodeRPC().UpdateAPINode(this.AdminContext(), &pb.UpdateAPINodeRequest{
|
||||||
NodeId: params.NodeId,
|
ApiNodeId: params.NodeId,
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
Description: params.Description,
|
Description: params.Description,
|
||||||
HttpJSON: httpJSON,
|
HttpJSON: httpJSON,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func (this *CreateNodeAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNodes := apiNodesResp.Nodes
|
apiNodes := apiNodesResp.ApiNodes
|
||||||
apiEndpoints := []string{}
|
apiEndpoints := []string{}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func (this *InstallNodesAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, apiNode := range apiNodesResp.Nodes {
|
for _, apiNode := range apiNodesResp.ApiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (this *InstallAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNodes := apiNodesResp.Nodes
|
apiNodes := apiNodesResp.ApiNodes
|
||||||
apiEndpoints := []string{}
|
apiEndpoints := []string{}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func SendMessageToCluster(ctx context.Context, clusterId int64, code string, msg
|
|||||||
apiNodeId := node.ConnectedAPINodeIds[0]
|
apiNodeId := node.ConnectedAPINodeIds[0]
|
||||||
rpcClient, ok := rpcMap[apiNodeId]
|
rpcClient, ok := rpcMap[apiNodeId]
|
||||||
if !ok {
|
if !ok {
|
||||||
apiNodeResp, err := defaultRPCClient.APINodeRPC().FindEnabledAPINode(ctx, &pb.FindEnabledAPINodeRequest{NodeId: apiNodeId})
|
apiNodeResp, err := defaultRPCClient.APINodeRPC().FindEnabledAPINode(ctx, &pb.FindEnabledAPINodeRequest{ApiNodeId: apiNodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
results = append(results, &MessageResult{
|
results = append(results, &MessageResult{
|
||||||
@@ -82,7 +82,7 @@ func SendMessageToCluster(ctx context.Context, clusterId int64, code string, msg
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if apiNodeResp.Node == nil {
|
if apiNodeResp.ApiNode == nil {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
results = append(results, &MessageResult{
|
results = append(results, &MessageResult{
|
||||||
NodeId: node.Id,
|
NodeId: node.Id,
|
||||||
@@ -94,7 +94,7 @@ func SendMessageToCluster(ctx context.Context, clusterId int64, code string, msg
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiNode := apiNodeResp.Node
|
apiNode := apiNodeResp.ApiNode
|
||||||
|
|
||||||
apiRPCClient, err := rpc.NewRPCClient(&configs.APIConfig{
|
apiRPCClient, err := rpc.NewRPCClient(&configs.APIConfig{
|
||||||
RPC: struct {
|
RPC: struct {
|
||||||
@@ -243,7 +243,7 @@ func SendMessageToNodeIds(ctx context.Context, nodeIds []int64, code string, msg
|
|||||||
apiNodeId := node.ConnectedAPINodeIds[0]
|
apiNodeId := node.ConnectedAPINodeIds[0]
|
||||||
rpcClient, ok := rpcMap[apiNodeId]
|
rpcClient, ok := rpcMap[apiNodeId]
|
||||||
if !ok {
|
if !ok {
|
||||||
apiNodeResp, err := defaultRPCClient.APINodeRPC().FindEnabledAPINode(ctx, &pb.FindEnabledAPINodeRequest{NodeId: apiNodeId})
|
apiNodeResp, err := defaultRPCClient.APINodeRPC().FindEnabledAPINode(ctx, &pb.FindEnabledAPINodeRequest{ApiNodeId: apiNodeId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
results = append(results, &MessageResult{
|
results = append(results, &MessageResult{
|
||||||
@@ -257,7 +257,7 @@ func SendMessageToNodeIds(ctx context.Context, nodeIds []int64, code string, msg
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if apiNodeResp.Node == nil {
|
if apiNodeResp.ApiNode == nil {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
results = append(results, &MessageResult{
|
results = append(results, &MessageResult{
|
||||||
NodeId: node.Id,
|
NodeId: node.Id,
|
||||||
@@ -269,7 +269,7 @@ func SendMessageToNodeIds(ctx context.Context, nodeIds []int64, code string, msg
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiNode := apiNodeResp.Node
|
apiNode := apiNodeResp.ApiNode
|
||||||
|
|
||||||
apiRPCClient, err := rpc.NewRPCClient(&configs.APIConfig{
|
apiRPCClient, err := rpc.NewRPCClient(&configs.APIConfig{
|
||||||
RPC: struct {
|
RPC: struct {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func (this *InstallAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNodes := apiNodesResp.Nodes
|
apiNodes := apiNodesResp.ApiNodes
|
||||||
apiEndpoints := []string{}
|
apiEndpoints := []string{}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func (this *UpdateHostsAction) RunPost(params struct {
|
|||||||
this.Fail("获取API节点列表失败,错误信息:" + err.Error())
|
this.Fail("获取API节点列表失败,错误信息:" + err.Error())
|
||||||
}
|
}
|
||||||
var endpoints = []string{}
|
var endpoints = []string{}
|
||||||
for _, node := range nodesResp.Nodes {
|
for _, node := range nodesResp.ApiNodes {
|
||||||
if !node.IsOn {
|
if !node.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ func (this *UpdateHostsAction) RunPost(params struct {
|
|||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
_, err = client.APINodeRPC().UpdateAPINode(client.Context(0), &pb.UpdateAPINodeRequest{
|
_, err = client.APINodeRPC().UpdateAPINode(client.Context(0), &pb.UpdateAPINodeRequest{
|
||||||
NodeId: node.Id,
|
ApiNodeId: node.Id,
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Description: node.Description,
|
Description: node.Description,
|
||||||
HttpJSON: node.HttpJSON,
|
HttpJSON: node.HttpJSON,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (this *ValidateApiAction) RunPost(params struct {
|
|||||||
this.Fail("获取API节点列表失败,错误信息:" + err.Error())
|
this.Fail("获取API节点列表失败,错误信息:" + err.Error())
|
||||||
}
|
}
|
||||||
var hosts = []string{}
|
var hosts = []string{}
|
||||||
for _, node := range nodesResp.Nodes {
|
for _, node := range nodesResp.ApiNodes {
|
||||||
if !node.IsOn {
|
if !node.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (this *InstallAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNodes := apiNodesResp.Nodes
|
apiNodes := apiNodesResp.ApiNodes
|
||||||
apiEndpoints := []string{}
|
apiEndpoints := []string{}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (this *InstallAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNodes := apiNodesResp.Nodes
|
apiNodes := apiNodesResp.ApiNodes
|
||||||
apiEndpoints := []string{}
|
apiEndpoints := []string{}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (this *InstallAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
apiNodes := apiNodesResp.Nodes
|
apiNodes := apiNodesResp.ApiNodes
|
||||||
apiEndpoints := []string{}
|
apiEndpoints := []string{}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if !apiNode.IsOn {
|
if !apiNode.IsOn {
|
||||||
|
|||||||
Reference in New Issue
Block a user