class NacosDiscoveryClient implements DiscoveryClient {
    private NamingService namingService;
    private ConnectConfig localConnectConfig;

    @Override
    public ConnectConfig buildConnectConfig(HttpsdProtocol httpsdProtocol) {
        return ConnectConfig.builder()
                .host(httpsdProtocol.getHost())
                .port(Integer.parseInt(httpsdProtocol.getPort()))
                .build();
    }

    @Override
    public void initClient(ConnectConfig connectConfig) {
        try {
            localConnectConfig = connectConfig;
            namingService = NamingFactory.createNamingService(connectConfig.getHost() + ":" + connectConfig.getPort());
        }catch (NacosException exception) {
            throw new RuntimeException("Failed to init namingService");
        }
    }

    @Override
    public ServerInfo getServerInfo() {
        if (Objects.isNull(namingService)) {
            throw new NullPointerException("NamingService is null");
        }
        String serverStatus = namingService.getServerStatus();
        return switch (serverStatus) {
            case "UP" -> ServerInfo.builder()
                    .address(localConnectConfig.getHost())
                    .port(String.valueOf(localConnectConfig.getPort()))
                    .build();
            case "DOWN" -> throw new RuntimeException("Nacos connection failed");
            default -> throw new RuntimeException("ServerStatus must be UP or DOWN");
        };
    }

    @Override
    public List<ServiceInstance> getServices() {<FILL_FUNCTION_BODY>}

    @Override
    public void close() {
        if (namingService == null) {
            return;
        }

        try {
            namingService.shutDown();
        }catch (NacosException ignore) {
        }
    }
}

        if (Objects.isNull(namingService)) {
            return Collections.emptyList();
        }
        List<ServiceInstance> serviceInstanceList = Lists.newArrayList();
        try {
            for (String serviceName : namingService.getServicesOfServer(0, 9999).getData()) {
                namingService.getAllInstances(serviceName).forEach(instance ->
                        serviceInstanceList.add(ServiceInstance.builder()
                                .serviceId(instance.getInstanceId())
                                .serviceName(instance.getServiceName())
                                .address(instance.getIp())
                                .port(String.valueOf(instance.getPort()))
                                .healthStatus(instance.isHealthy() ? "UP" : "DOWN")
                                .build()));
            }
        } catch (NacosException e) {
            throw new RuntimeException("Failed to fetch instance info");
        }

        return serviceInstanceList;
    
<no_super_class>