zhaowenyu
2026-02-12 e18802f171fb12246a8bad5a699c55c630a6d2e3
ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java
@@ -5,10 +5,12 @@
import com.dtflys.forest.callback.AddressSource;
import com.dtflys.forest.http.ForestAddress;
import com.dtflys.forest.http.ForestRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Slf4j
@Component
public class MyAddressSource implements AddressSource {
@@ -17,7 +19,15 @@
    @Override
    public ForestAddress getAddress(ForestRequest request) {
        String serverKey = request.varAsString("serverId");
        if(serverKey == null){
            log.warn("请求属性serverId为空");
            return null;
        }
        ArdServerInfo serverInfo = ardServerService.selectArdServerInfoById(serverKey);
        if(serverInfo == null){
            log.warn("边缘服务器不存在");
            return null;
        }
        // 返回 Forest 地址对象
        return new ForestAddress(serverInfo.getHost(), serverInfo.getHttpPort());
    }