forked from Gitlink/microservices
feat(运维监控模块): 新增接口:获取微服务应用功能列表
1. REGISTRATION_CENTER:调用 Nacos 接口获取服务列表,匹配服务名与标签值,构造注册中心功能对象。 2. GATEWAY_MANAGEMENT:模糊匹配 Nacos 配置中的 dataId,若包含标签值则构造网关管理功能对象。
This commit is contained in:
parent
c3b5dcafba
commit
18f89d1b8e
|
|
@ -68,6 +68,13 @@ public interface RemoteGatewayService {
|
|||
@PostMapping("/skywalking/graphql")
|
||||
JSONObject executeSkywalkingGql(@RequestBody GraphqlQueryVo gqlBody);
|
||||
|
||||
@GetMapping("/sentinel//app/briefinfos.json")
|
||||
@GetMapping("/sentinel/app/briefinfos.json")
|
||||
JSONObject getSentinelAppList(@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
@GetMapping("/nacos/v1/ns/catalog/services?pageNo=1&pageSize=999")
|
||||
JSONObject getNacosServiceList(@RequestParam("serviceNameParam") String serviceNameParam,@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
|
||||
|
||||
@GetMapping("/nacos/v1/cs/configs?types=yaml&search=blur&group=&pageNo=1&pageSize=10")
|
||||
JSONObject getNacosConfigList(@RequestParam("dataId") String dataId,@RequestHeader(TokenConstants.AUTHENTICATION) String token);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,16 @@ public class RemoteGatewayFallbackFactory implements FallbackFactory<RemoteGatew
|
|||
public JSONObject getSentinelAppList(String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getNacosServiceList(String serviceNameParam, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getNacosConfigList(String dataId, String token) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,13 +295,43 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
|
|||
break;
|
||||
case REGISTRATION_CENTER:
|
||||
// 处理应用注册中心功能相关逻辑
|
||||
JSONObject nacosServiceList = remoteGatewayService.getNacosServiceList(k8sLabelValue, SecurityContextHolder.getUserKey());
|
||||
if (nacosServiceList != null && nacosServiceList.getJSONArray("serviceList") != null && !nacosServiceList.getJSONArray("serviceList").isEmpty()) {
|
||||
JSONArray nacosServiceListArray = nacosServiceList.getJSONArray("serviceList");
|
||||
for (int i = 0; i < nacosServiceListArray.size(); i++) {
|
||||
JSONObject nacosService = nacosServiceListArray.getJSONObject(i);
|
||||
if (k8sLabelValue.equals(nacosService.getString("name"))) {
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(applicationFunctionType);
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables.put("name", k8sLabelValue);
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
applicationFunctionsList.add(applicationFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GATEWAY_MANAGEMENT:
|
||||
// 处理应用网关管理功能相关逻辑
|
||||
JSONObject nacosConfigList = remoteGatewayService.getNacosConfigList(String.format("*%s*", k8sLabelValue), SecurityContextHolder.getUserKey());
|
||||
if (nacosConfigList != null && nacosConfigList.getJSONArray("pageItems") != null && !nacosConfigList.getJSONArray("pageItems").isEmpty()) {
|
||||
JSONArray nacosConfigListJSONArray = nacosConfigList.getJSONArray("pageItems");
|
||||
for (int i = 0; i < nacosConfigListJSONArray.size(); i++) {
|
||||
JSONObject nacosService = nacosConfigListJSONArray.getJSONObject(i);
|
||||
String dataId = nacosService.getString("dataId");
|
||||
if (StringUtils.isNotEmpty(dataId) && dataId.contains(k8sLabelValue)) {
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(applicationFunctionType);
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables.put("dataId", dataId);
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
applicationFunctionsList.add(applicationFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return applicationFunctionsList;
|
||||
|
|
|
|||
Loading…
Reference in New Issue