【8.3.0】【resource】完善资源汇报devops的配置

master
stylefeng 2024-10-06 22:08:30 +08:00
parent 5bee81ad23
commit 521e182672
1 changed files with 11 additions and 8 deletions

View File

@ -44,6 +44,7 @@ import org.springframework.core.Ordered;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
*
@ -79,9 +80,7 @@ public class ResourceReportListener extends ApplicationReadyListener implements
// 持久化资源,发送资源到资源服务或本项目
ResourceReportApi resourceService = applicationContext.getBean(ResourceReportApi.class);
List<SysResourcePersistencePojo> persistencePojos = resourceService.reportResourcesAndGetResult(new ReportResourceParam(scannerProperties.getAppCode(), modularResources));
long saveLocalFinish = System.currentTimeMillis();
log.info("存储本地接口资源完成,耗时:{}ms", (saveLocalFinish - beginSaveLocal));
log.info("存储本地接口资源完成,耗时:{}ms", (System.currentTimeMillis() - beginSaveLocal));
// 向DevOps一体化平台汇报资源只有两种情况会汇报资源1.本地配置了远程服务器地址2.本地化集成了devops模块
DevOpsReportProperties devOpsReportProperties = applicationContext.getBean(DevOpsReportProperties.class);
@ -94,12 +93,16 @@ public class ResourceReportListener extends ApplicationReadyListener implements
// 判断是否配置了host或者本地有集成化的devops平台
if (ObjectUtil.isNotEmpty(devOpsReportProperties.getServerHost()) || devOpsDetectApi != null) {
DevOpsReportApi devOpsReportApi = applicationContext.getBean(DevOpsReportApi.class);
try {
// 异步化汇报给devops
CompletableFuture.runAsync(() -> {
long beginDevopsReport = System.currentTimeMillis();
devOpsReportApi.reportResources(devOpsReportProperties, persistencePojos);
log.info("向DevOps平台汇报资源信息完成耗时{}ms", (System.currentTimeMillis() - saveLocalFinish));
} catch (Exception e) {
log.error("向DevOps平台汇报异常出现网络错误如无法联通DevOps平台可关闭相关配置。", e);
}
log.info("向DevOps平台汇报资源信息完成耗时{}ms", (System.currentTimeMillis() - beginDevopsReport));
}).exceptionally(ex -> {
log.error("向DevOps平台汇报异常出现网络错误如无法联通DevOps平台可关闭相关配置。", ex);
return null;
});
}
// 设置标识已经扫描过