feat: 获取app step 4

This commit is contained in:
zengxiaobo 2024-07-04 18:57:36 +08:00
parent 8431e71fde
commit 105481f94b

View File

@ -26,6 +26,7 @@ public class AppCenterImpl implements AppCenter {
private RpcClient rpcClient;
private String debugHost;
private String listAppUrl;
private Map<String, String> debugAppRoutes;
/**
@ -46,14 +47,15 @@ public class AppCenterImpl implements AppCenter {
this.appCache = new TimerRefreshCache<>("appCenterCache", INITIAL_DELAY_MILLIS,
REFRESH_INTERVAL_MILLIS, executor, this::loadApps);
this.debugHost = debugHost;
this.listAppUrl = Optional.ofNullable(Strings.emptyToNull(debugHost)).map(e -> e + "/apisix-plat").orElse("http://apisix-plat:8080")
+ "/api/v1/upstream/list";
this.debugAppRoutes = Optional.ofNullable(debugAppRoutes).orElse(ImmutableMap.of());
}
private Map<String, App> loadApps() {
String host = Optional.ofNullable(debugHost).map(e -> e + "/apisix-plat").orElse("http://apisix-plat:8080");
List<App> apps = PageUtils.drainAll(page -> {
JSONObject result = rpcClient.request()
.url(host + "/api/v1/upstream/list")
.url(listAppUrl)
.content(new JSONObject()
.fluentPut("pageNum", page)
.fluentPut("pageSize", 50))