Drop overlapping configuration in reactive implementation (#1525)
This commit is contained in:
@@ -80,8 +80,7 @@ public class KubernetesDiscoveryClient implements DiscoveryClient {
|
||||
public List<String> getServices() {
|
||||
Service[] services = rest.getForEntity(discoveryServerUrl + "/apps", Service[].class).getBody();
|
||||
if (services != null && services.length > 0) {
|
||||
return Arrays.stream(services).filter(this::matchNamespaces).map(Service::getName)
|
||||
.collect(Collectors.toList());
|
||||
return Arrays.stream(services).filter(this::matchNamespaces).map(Service::getName).toList();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.cloud.kubernetes.commons.PodUtils;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnSpringCloudKubernetesReactiveDiscovery;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnSpringCloudKubernetesReactiveDiscoveryHealthInitializer;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryClientHealthIndicatorInitializer;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -34,8 +35,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnSpringCloudKubernetesReactiveDiscovery
|
||||
@EnableConfigurationProperties({ DiscoveryClientHealthIndicatorProperties.class,
|
||||
KubernetesDiscoveryClientProperties.class })
|
||||
@EnableConfigurationProperties({ DiscoveryClientHealthIndicatorProperties.class, KubernetesDiscoveryProperties.class })
|
||||
class KubernetesDiscoveryClientReactiveAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -47,7 +47,7 @@ class KubernetesDiscoveryClientReactiveAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
KubernetesReactiveDiscoveryClient kubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder,
|
||||
KubernetesDiscoveryClientProperties properties) {
|
||||
KubernetesDiscoveryProperties properties) {
|
||||
return new KubernetesReactiveDiscoveryClient(webClientBuilder, properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import reactor.core.publisher.Flux;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
@@ -31,6 +32,7 @@ public class KubernetesReactiveDiscoveryClient implements ReactiveDiscoveryClien
|
||||
|
||||
private final WebClient webClient;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public KubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder,
|
||||
KubernetesDiscoveryClientProperties properties) {
|
||||
if (!StringUtils.hasText(properties.getDiscoveryServerUrl())) {
|
||||
@@ -39,6 +41,13 @@ public class KubernetesReactiveDiscoveryClient implements ReactiveDiscoveryClien
|
||||
this.webClient = webClientBuilder.baseUrl(properties.getDiscoveryServerUrl()).build();
|
||||
}
|
||||
|
||||
KubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, KubernetesDiscoveryProperties properties) {
|
||||
if (!StringUtils.hasText(properties.discoveryServerUrl())) {
|
||||
throw new DiscoveryServerUrlInvalidException();
|
||||
}
|
||||
this.webClient = webClientBuilder.baseUrl(properties.discoveryServerUrl()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Reactive Kubernetes Discovery Client";
|
||||
|
||||
Reference in New Issue
Block a user