mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
fix(performance): CommonUtil initConfig 改为异步非阻塞读取
This commit is contained in:
@@ -100,18 +100,21 @@ public class CommonUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理其他配置
|
* 处理其他配置(异步非阻塞方式)
|
||||||
*
|
*
|
||||||
* @param configName configName
|
* @param configName configName
|
||||||
*/
|
*/
|
||||||
public static void initConfig(String configName, Class<?> tClass) {
|
public static void initConfig(String configName, Class<?> tClass) {
|
||||||
URL resource = tClass.getResource("/conf/" + configName);
|
URL resource = tClass.getResource("/conf/" + configName);
|
||||||
if (resource == null) throw new RuntimeException("路径不存在");
|
if (resource == null) throw new RuntimeException("路径不存在");
|
||||||
Buffer buffer = VertxHolder.getVertxInstance().fileSystem().readFileBlocking(resource.getPath());
|
VertxHolder.getVertxInstance().fileSystem().readFile(resource.getPath())
|
||||||
JsonObject entries = new JsonObject(buffer);
|
.onSuccess(buffer -> {
|
||||||
Map<String, Object> map = entries.getMap();
|
JsonObject entries = new JsonObject(buffer);
|
||||||
LocalConstant.put(configName, map);
|
Map<String, Object> map = entries.getMap();
|
||||||
LOGGER.info("读取配置{}成功", configName);
|
LocalConstant.put(configName, map);
|
||||||
|
LOGGER.info("读取配置{}成功", configName);
|
||||||
|
})
|
||||||
|
.onFailure(err -> LOGGER.error("读取配置{}失败", configName, err));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Set<T> sortClassSet(Set<Class<? extends T>> set) {
|
public static <T> Set<T> sortClassSet(Set<Class<? extends T>> set) {
|
||||||
|
|||||||
Reference in New Issue
Block a user