diff --git a/common/src/main/java/com/github/dynamic/threadpool/common/model/InstanceInfo.java b/common/src/main/java/com/github/dynamic/threadpool/common/model/InstanceInfo.java
index 714e51bd..88cb054d 100644
--- a/common/src/main/java/com/github/dynamic/threadpool/common/model/InstanceInfo.java
+++ b/common/src/main/java/com/github/dynamic/threadpool/common/model/InstanceInfo.java
@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Getter
@Setter
+@Accessors(chain = true)
public class InstanceInfo {
private static final String UNKNOWN = "unknown";
@@ -23,10 +24,16 @@ public class InstanceInfo {
private String hostName;
+ private String port;
+
private String instanceId;
private String ipApplicationName;
+ private String clientBasePath;
+
+ private String callBackUrl;
+
private volatile String vipAddress;
private volatile String secureVipAddress;
diff --git a/console/pom.xml b/console/pom.xml
index f66de5ce..c7b98a8f 100644
--- a/console/pom.xml
+++ b/console/pom.xml
@@ -20,6 +20,11 @@
com.github.dynamic-threadpool
config
+
+
+ com.github.dynamic-threadpool
+ discovery
+
diff --git a/console/src/main/java/com/github/dynamic/threadpool/console/controller/ThreadPoolController.java b/console/src/main/java/com/github/dynamic/threadpool/console/controller/ThreadPoolController.java
index 004d6209..d25dabd9 100644
--- a/console/src/main/java/com/github/dynamic/threadpool/console/controller/ThreadPoolController.java
+++ b/console/src/main/java/com/github/dynamic/threadpool/console/controller/ThreadPoolController.java
@@ -2,17 +2,19 @@ package com.github.dynamic.threadpool.console.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.dynamic.threadpool.common.constant.Constants;
+import com.github.dynamic.threadpool.common.model.InstanceInfo;
import com.github.dynamic.threadpool.common.web.base.Result;
import com.github.dynamic.threadpool.common.web.base.Results;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolQueryReqDTO;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
import com.github.dynamic.threadpool.config.service.biz.ThreadPoolService;
+import com.github.dynamic.threadpool.discovery.core.BaseInstanceRegistry;
+import com.github.dynamic.threadpool.discovery.core.Lease;
import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
/**
* Thread pool controller.
@@ -27,6 +29,8 @@ public class ThreadPoolController {
private final ThreadPoolService threadPoolService;
+ private final BaseInstanceRegistry baseInstanceRegistry;
+
@PostMapping("/pool/query/page")
public Result> queryNameSpacePage(@RequestBody ThreadPoolQueryReqDTO reqDTO) {
return Results.success(threadPoolService.queryThreadPoolPage(reqDTO));
@@ -43,4 +47,10 @@ public class ThreadPoolController {
return Results.success();
}
+ @GetMapping("/pool/list/instance/{itemId}")
+ public Result>> listInstance(@PathVariable("itemId") String itemId) {
+ List> leases = baseInstanceRegistry.listInstance(itemId);
+ return Results.success(leases);
+ }
+
}
diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DiscoveryConfig.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DiscoveryConfig.java
index 99c479bf..4e2f6950 100644
--- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DiscoveryConfig.java
+++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/config/DiscoveryConfig.java
@@ -28,10 +28,15 @@ public class DiscoveryConfig {
@SneakyThrows
public InstanceInfo instanceConfig() {
InstanceInfo instanceInfo = new InstanceInfo();
- instanceInfo.setInstanceId(getDefaultInstanceId(environment));
- instanceInfo.setIpApplicationName(getIpApplicationName(environment));
- instanceInfo.setAppName(environment.getProperty("spring.application.name"));
- instanceInfo.setHostName(InetAddress.getLocalHost().getHostAddress());
+ instanceInfo.setInstanceId(getDefaultInstanceId(environment))
+ .setIpApplicationName(getIpApplicationName(environment))
+ .setHostName(InetAddress.getLocalHost().getHostAddress())
+ .setAppName(environment.getProperty("spring.application.name"))
+ .setClientBasePath(environment.getProperty("server.servlet.context-path"));
+ String callBackUrl = new StringBuilder().append(instanceInfo.getHostName()).append(":")
+ .append(environment.getProperty("server.port")).append(instanceInfo.getClientBasePath())
+ .toString();
+ instanceInfo.setCallBackUrl(callBackUrl);
return instanceInfo;
}