diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableBlockingDisabled.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableBlockingDisabled.java new file mode 100644 index 0000000000..9d10278f06 --- /dev/null +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableBlockingDisabled.java @@ -0,0 +1,54 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.commons.discovery; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; +import org.springframework.context.annotation.Conditional; + +/** + * Reverse of {@link ConditionalOnDiscoveryCacheableBlockingEnabled}. + * + * @author wind57 + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Conditional(ConditionalOnDiscoveryCacheableBlockingDisabled.OnDiscoveryCacheableBlockingDisabled.class) +public @interface ConditionalOnDiscoveryCacheableBlockingDisabled { + + class OnDiscoveryCacheableBlockingDisabled extends NoneNestedConditions { + + OnDiscoveryCacheableBlockingDisabled() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnDiscoveryCacheableBlockingEnabled + static class OnDisabled { + + } + + } + +} diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableBlockingEnabled.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableBlockingEnabled.java new file mode 100644 index 0000000000..931121757d --- /dev/null +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableBlockingEnabled.java @@ -0,0 +1,43 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.commons.discovery; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; + +/** + * Provides a more succinct conditional for: + * spring.cloud.kubernetes.discovery.cacheable.blocking.enabled. This + * annotation says that caching in the blocking implementation is enabled. + * + * @author wind57 + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@ConditionalOnProperty(value = "spring.cloud.kubernetes.discovery.cacheable.blocking.enabled", havingValue = "true", + matchIfMissing = false) +public @interface ConditionalOnDiscoveryCacheableBlockingEnabled { + +} diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableReactiveDisabled.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableReactiveDisabled.java new file mode 100644 index 0000000000..373c704f9f --- /dev/null +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableReactiveDisabled.java @@ -0,0 +1,54 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.commons.discovery; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; +import org.springframework.context.annotation.Conditional; + +/** + * Reverse of {@link ConditionalOnDiscoveryCacheableReactiveEnabled}. + * + * @author wind57 + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Conditional(ConditionalOnDiscoveryCacheableReactiveDisabled.OnDiscoveryCacheableReactiveDisabled.class) +public @interface ConditionalOnDiscoveryCacheableReactiveDisabled { + + class OnDiscoveryCacheableReactiveDisabled extends NoneNestedConditions { + + OnDiscoveryCacheableReactiveDisabled() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnDiscoveryCacheableReactiveEnabled + static class OnDisabled { + + } + + } + +} diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableReactiveEnabled.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableReactiveEnabled.java new file mode 100644 index 0000000000..becf619996 --- /dev/null +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/discovery/ConditionalOnDiscoveryCacheableReactiveEnabled.java @@ -0,0 +1,43 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.commons.discovery; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; + +/** + * Provides a more succinct conditional for: + * spring.cloud.kubernetes.discovery.cacheable.reactive.enabled. This + * annotation says that caching in the reactive implementation is enabled. + * + * @author wind57 + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@ConditionalOnProperty(value = "spring.cloud.kubernetes.discovery.cacheable.reactive.enabled", havingValue = "true", + matchIfMissing = false) +public @interface ConditionalOnDiscoveryCacheableReactiveEnabled { + +} diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8AbstractBlockingDiscoveryClient.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8AbstractBlockingDiscoveryClient.java new file mode 100644 index 0000000000..1bcb4c73ba --- /dev/null +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8AbstractBlockingDiscoveryClient.java @@ -0,0 +1,175 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.fabric8.discovery; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Predicate; + +import io.fabric8.kubernetes.api.model.EndpointAddress; +import io.fabric8.kubernetes.api.model.EndpointSubset; +import io.fabric8.kubernetes.api.model.Endpoints; +import io.fabric8.kubernetes.api.model.Service; +import io.fabric8.kubernetes.client.KubernetesClient; +import org.apache.commons.logging.LogFactory; + +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; +import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties; +import org.springframework.cloud.kubernetes.commons.discovery.ServiceMetadata; +import org.springframework.cloud.kubernetes.commons.discovery.ServicePortNameAndNumber; +import org.springframework.cloud.kubernetes.commons.discovery.ServicePortSecureResolver; +import org.springframework.core.log.LogAccessor; + +import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.endpointsPort; +import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.externalNameServiceInstance; +import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.serviceInstance; +import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.serviceInstanceMetadata; +import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.EXTERNAL_NAME; +import static org.springframework.cloud.kubernetes.fabric8.Fabric8Utils.serviceMetadata; +import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.addresses; +import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.endpointSubsetsPortData; +import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.endpoints; +import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.services; +import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8InstanceIdHostPodNameSupplier.externalName; +import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8InstanceIdHostPodNameSupplier.nonExternalName; + +/** + * @author wind57 + */ +abstract class Fabric8AbstractBlockingDiscoveryClient implements DiscoveryClient { + + private static final LogAccessor LOG = new LogAccessor( + LogFactory.getLog(Fabric8AbstractBlockingDiscoveryClient.class)); + + private final KubernetesDiscoveryProperties properties; + + private final ServicePortSecureResolver servicePortSecureResolver; + + private final KubernetesClient client; + + private final KubernetesNamespaceProvider namespaceProvider; + + private final Predicate predicate; + + Fabric8AbstractBlockingDiscoveryClient(KubernetesClient client, + KubernetesDiscoveryProperties kubernetesDiscoveryProperties, + ServicePortSecureResolver servicePortSecureResolver, KubernetesNamespaceProvider namespaceProvider, + Predicate predicate) { + + this.client = client; + this.properties = kubernetesDiscoveryProperties; + this.servicePortSecureResolver = servicePortSecureResolver; + this.namespaceProvider = namespaceProvider; + this.predicate = predicate; + } + + public abstract String description(); + + @Override + public List getInstances(String serviceId) { + Objects.requireNonNull(serviceId); + + List allEndpoints = endpoints(properties, client, namespaceProvider, "fabric8-discovery", serviceId, + predicate); + + List instances = new ArrayList<>(); + for (Endpoints endpoints : allEndpoints) { + // endpoints are only those that matched the serviceId + instances.addAll(serviceInstances(endpoints, serviceId)); + } + + if (properties.includeExternalNameServices()) { + LOG.debug(() -> "Searching for 'ExternalName' type of services with serviceId : " + serviceId); + List services = services(properties, client, namespaceProvider, + s -> s.getSpec().getType().equals(EXTERNAL_NAME), Map.of("metadata.name", serviceId), + "fabric8-discovery"); + for (Service service : services) { + ServiceMetadata serviceMetadata = serviceMetadata(service); + Map serviceInstanceMetadata = serviceInstanceMetadata(Map.of(), serviceMetadata, + properties); + + Fabric8InstanceIdHostPodNameSupplier supplierOne = externalName(service); + + ServiceInstance externalNameServiceInstance = externalNameServiceInstance(serviceMetadata, supplierOne, + serviceInstanceMetadata); + + instances.add(externalNameServiceInstance); + } + } + + return instances; + } + + @Override + public List getServices() { + List services = services(properties, client, namespaceProvider, predicate, null, "fabric8 discovery") + .stream() + .map(service -> service.getMetadata().getName()) + .distinct() + .toList(); + LOG.debug(() -> "will return services : " + services); + return services; + } + + @Override + public int getOrder() { + return properties.order(); + } + + private List serviceInstances(Endpoints endpoints, String serviceId) { + + List subsets = endpoints.getSubsets(); + if (subsets.isEmpty()) { + LOG.debug(() -> "serviceId : " + serviceId + " does not have any subsets"); + return List.of(); + } + + String namespace = endpoints.getMetadata().getNamespace(); + List instances = new ArrayList<>(); + + Service service = client.services().inNamespace(namespace).withName(serviceId).get(); + ServiceMetadata serviceMetadata = serviceMetadata(service); + Map portsData = endpointSubsetsPortData(subsets); + + Map serviceInstanceMetadata = serviceInstanceMetadata(portsData, serviceMetadata, properties); + + for (EndpointSubset endpointSubset : subsets) { + + Map endpointsPortData = endpointSubsetsPortData(List.of(endpointSubset)); + ServicePortNameAndNumber portData = endpointsPort(endpointsPortData, serviceMetadata, properties); + + List addresses = addresses(endpointSubset, properties); + for (EndpointAddress endpointAddress : addresses) { + + Fabric8InstanceIdHostPodNameSupplier supplierOne = nonExternalName(endpointAddress, service); + Fabric8PodLabelsAndAnnotationsSupplier supplierTwo = Fabric8PodLabelsAndAnnotationsSupplier + .nonExternalName(client, namespace); + + ServiceInstance serviceInstance = serviceInstance(servicePortSecureResolver, serviceMetadata, + supplierOne, supplierTwo, portData, serviceInstanceMetadata, properties); + instances.add(serviceInstance); + } + } + + return instances; + } + +} diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8AbstractReactiveDiscoveryClient.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8AbstractReactiveDiscoveryClient.java new file mode 100644 index 0000000000..e230cf119f --- /dev/null +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8AbstractReactiveDiscoveryClient.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.fabric8.discovery; + +import java.util.Objects; + +import reactor.core.publisher.Flux; +import reactor.core.scheduler.Schedulers; + +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; + +/** + * @author wind57 + */ +abstract class Fabric8AbstractReactiveDiscoveryClient implements ReactiveDiscoveryClient { + + private final Fabric8DiscoveryClient fabric8DiscoveryClient; + + Fabric8AbstractReactiveDiscoveryClient(Fabric8DiscoveryClient fabric8DiscoveryClient) { + this.fabric8DiscoveryClient = fabric8DiscoveryClient; + } + + @Override + public Flux getServices() { + return Flux.defer(() -> Flux.fromIterable(fabric8DiscoveryClient.getServices())) + .subscribeOn(Schedulers.boundedElastic()); + } + + @Override + public Flux getInstances(String serviceId) { + Objects.requireNonNull(serviceId, "serviceId must not be null"); + return Flux.defer(() -> Flux.fromIterable(fabric8DiscoveryClient.getInstances(serviceId))) + .subscribeOn(Schedulers.boundedElastic()); + } + + @Override + public abstract String description(); + + @Override + public int getOrder() { + return fabric8DiscoveryClient.getOrder(); + } + +} diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8CacheableDiscoveryClient.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8CacheableDiscoveryClient.java new file mode 100644 index 0000000000..b44571631e --- /dev/null +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8CacheableDiscoveryClient.java @@ -0,0 +1,70 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.fabric8.discovery; + +import java.util.List; +import java.util.function.Predicate; + +import io.fabric8.kubernetes.api.model.Service; +import io.fabric8.kubernetes.client.KubernetesClient; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; +import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties; +import org.springframework.cloud.kubernetes.commons.discovery.ServicePortSecureResolver; + +/** + * Cacheable Fabric8 Kubernetes implementation of {@link DiscoveryClient}. + * + * @author Ioannis Canellos + * @author Tim Ysewyn + */ +class Fabric8CacheableDiscoveryClient extends Fabric8AbstractBlockingDiscoveryClient { + + Fabric8CacheableDiscoveryClient(KubernetesClient client, + KubernetesDiscoveryProperties kubernetesDiscoveryProperties, + ServicePortSecureResolver servicePortSecureResolver, KubernetesNamespaceProvider namespaceProvider, + Predicate predicate) { + + super(client, kubernetesDiscoveryProperties, servicePortSecureResolver, namespaceProvider, predicate); + } + + @Override + @Cacheable("fabric8-blocking-discovery-services") + public List getServices() { + return super.getServices(); + } + + @Override + @Cacheable("fabric8-blocking-discovery-instances") + public List getInstances(String serviceId) { + return super.getInstances(serviceId); + } + + @Override + public String description() { + return "Fabric8 Cacheable Blocking Discovery Client"; + } + + @Override + public int getOrder() { + return super.getOrder(); + } + +} diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8CacheableReactiveDiscoveryClient.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8CacheableReactiveDiscoveryClient.java new file mode 100644 index 0000000000..aafbc037c8 --- /dev/null +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8CacheableReactiveDiscoveryClient.java @@ -0,0 +1,55 @@ +/* + * Copyright 2013-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.fabric8.discovery; + +import java.util.Objects; + +import reactor.core.publisher.Flux; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.cloud.client.ServiceInstance; + +public class Fabric8CacheableReactiveDiscoveryClient extends Fabric8AbstractReactiveDiscoveryClient { + + Fabric8CacheableReactiveDiscoveryClient(Fabric8DiscoveryClient fabric8DiscoveryClient) { + super(fabric8DiscoveryClient); + } + + @Override + @Cacheable("fabric8-reactive-discovery-services") + public Flux getServices() { + return super.getServices(); + } + + @Override + @Cacheable("fabric8-reactive-discovery-instances") + public Flux getInstances(String serviceId) { + Objects.requireNonNull(serviceId, "serviceId must not be null"); + return super.getInstances(serviceId); + } + + @Override + public String description() { + return "Fabric8 Cacheable Reactive Discovery Client"; + } + + @Override + public int getOrder() { + return super.getOrder(); + } + +} diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClient.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClient.java index d650af623c..56c1ca3694 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClient.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClient.java @@ -16,41 +16,15 @@ package org.springframework.cloud.kubernetes.fabric8.discovery; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; import java.util.function.Predicate; -import io.fabric8.kubernetes.api.model.EndpointAddress; -import io.fabric8.kubernetes.api.model.EndpointSubset; -import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.client.KubernetesClient; -import org.apache.commons.logging.LogFactory; -import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties; -import org.springframework.cloud.kubernetes.commons.discovery.ServiceMetadata; -import org.springframework.cloud.kubernetes.commons.discovery.ServicePortNameAndNumber; import org.springframework.cloud.kubernetes.commons.discovery.ServicePortSecureResolver; -import org.springframework.core.log.LogAccessor; - -import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.endpointsPort; -import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.externalNameServiceInstance; -import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.serviceInstance; -import static org.springframework.cloud.kubernetes.commons.discovery.DiscoveryClientUtils.serviceInstanceMetadata; -import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.EXTERNAL_NAME; -import static org.springframework.cloud.kubernetes.fabric8.Fabric8Utils.serviceMetadata; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.addresses; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.endpointSubsetsPortData; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.endpoints; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8DiscoveryClientUtils.services; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8InstanceIdHostPodNameSupplier.externalName; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8InstanceIdHostPodNameSupplier.nonExternalName; -import static org.springframework.cloud.kubernetes.fabric8.discovery.Fabric8PodLabelsAndAnnotationsSupplier.nonExternalName; /** * Fabric8 Kubernetes implementation of {@link DiscoveryClient}. @@ -58,122 +32,18 @@ * @author Ioannis Canellos * @author Tim Ysewyn */ -final class Fabric8DiscoveryClient implements DiscoveryClient { - - private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(Fabric8DiscoveryClient.class)); - - private final KubernetesDiscoveryProperties properties; - - private final ServicePortSecureResolver servicePortSecureResolver; - - private final KubernetesClient client; - - private final KubernetesNamespaceProvider namespaceProvider; - - private final Predicate predicate; +final class Fabric8DiscoveryClient extends Fabric8AbstractBlockingDiscoveryClient { Fabric8DiscoveryClient(KubernetesClient client, KubernetesDiscoveryProperties kubernetesDiscoveryProperties, ServicePortSecureResolver servicePortSecureResolver, KubernetesNamespaceProvider namespaceProvider, Predicate predicate) { - this.client = client; - this.properties = kubernetesDiscoveryProperties; - this.servicePortSecureResolver = servicePortSecureResolver; - this.namespaceProvider = namespaceProvider; - this.predicate = predicate; + super(client, kubernetesDiscoveryProperties, servicePortSecureResolver, namespaceProvider, predicate); } @Override public String description() { - return "Fabric8 Kubernetes Discovery Client"; - } - - @Override - public List getInstances(String serviceId) { - Objects.requireNonNull(serviceId); - - List allEndpoints = endpoints(properties, client, namespaceProvider, "fabric8-discovery", serviceId, - predicate); - - List instances = new ArrayList<>(); - for (Endpoints endpoints : allEndpoints) { - // endpoints are only those that matched the serviceId - instances.addAll(serviceInstances(endpoints, serviceId)); - } - - if (properties.includeExternalNameServices()) { - LOG.debug(() -> "Searching for 'ExternalName' type of services with serviceId : " + serviceId); - List services = services(properties, client, namespaceProvider, - s -> s.getSpec().getType().equals(EXTERNAL_NAME), Map.of("metadata.name", serviceId), - "fabric8-discovery"); - for (Service service : services) { - ServiceMetadata serviceMetadata = serviceMetadata(service); - Map serviceInstanceMetadata = serviceInstanceMetadata(Map.of(), serviceMetadata, - properties); - - Fabric8InstanceIdHostPodNameSupplier supplierOne = externalName(service); - - ServiceInstance externalNameServiceInstance = externalNameServiceInstance(serviceMetadata, supplierOne, - serviceInstanceMetadata); - - instances.add(externalNameServiceInstance); - } - } - - return instances; - } - - @Override - public List getServices() { - List services = services(properties, client, namespaceProvider, predicate, null, "fabric8 discovery") - .stream() - .map(service -> service.getMetadata().getName()) - .distinct() - .toList(); - LOG.debug(() -> "will return services : " + services); - return services; - } - - @Override - public int getOrder() { - return properties.order(); - } - - private List serviceInstances(Endpoints endpoints, String serviceId) { - - List subsets = endpoints.getSubsets(); - if (subsets.isEmpty()) { - LOG.debug(() -> "serviceId : " + serviceId + " does not have any subsets"); - return List.of(); - } - - String namespace = endpoints.getMetadata().getNamespace(); - List instances = new ArrayList<>(); - - Service service = client.services().inNamespace(namespace).withName(serviceId).get(); - ServiceMetadata serviceMetadata = serviceMetadata(service); - Map portsData = endpointSubsetsPortData(subsets); - - Map serviceInstanceMetadata = serviceInstanceMetadata(portsData, serviceMetadata, properties); - - for (EndpointSubset endpointSubset : subsets) { - - Map endpointsPortData = endpointSubsetsPortData(List.of(endpointSubset)); - ServicePortNameAndNumber portData = endpointsPort(endpointsPortData, serviceMetadata, properties); - - List addresses = addresses(endpointSubset, properties); - for (EndpointAddress endpointAddress : addresses) { - - Fabric8InstanceIdHostPodNameSupplier supplierOne = nonExternalName(endpointAddress, service); - Fabric8PodLabelsAndAnnotationsSupplier supplierTwo = nonExternalName(client, namespace); - - ServiceInstance serviceInstance = serviceInstance(servicePortSecureResolver, serviceMetadata, - supplierOne, supplierTwo, portData, serviceInstanceMetadata, properties); - instances.add(serviceInstance); - } - } - - return instances; + return "Fabric8 Blocking Discovery Client"; } } diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfiguration.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfiguration.java index ede5dc3cb9..f25bbab5e3 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfiguration.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfiguration.java @@ -29,6 +29,8 @@ import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration; import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; import org.springframework.cloud.kubernetes.commons.PodUtils; +import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnDiscoveryCacheableBlockingDisabled; +import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnDiscoveryCacheableBlockingEnabled; import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnSpringCloudKubernetesBlockingDiscovery; import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnSpringCloudKubernetesBlockingDiscoveryHealthInitializer; import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryClientHealthIndicatorInitializer; @@ -60,6 +62,7 @@ final class Fabric8DiscoveryClientAutoConfiguration { @Bean @ConditionalOnMissingBean + @ConditionalOnDiscoveryCacheableBlockingDisabled Fabric8DiscoveryClient fabric8DiscoveryClient(KubernetesClient client, KubernetesDiscoveryProperties properties, Predicate predicate, Environment environment) { ServicePortSecureResolver servicePortSecureResolver = new ServicePortSecureResolver(properties); @@ -67,6 +70,17 @@ Fabric8DiscoveryClient fabric8DiscoveryClient(KubernetesClient client, Kubernete return new Fabric8DiscoveryClient(client, properties, servicePortSecureResolver, namespaceProvider, predicate); } + @Bean + @ConditionalOnMissingBean + @ConditionalOnDiscoveryCacheableBlockingEnabled + Fabric8CacheableDiscoveryClient fabric8CacheableDiscoveryClient(KubernetesClient client, + KubernetesDiscoveryProperties properties, Predicate predicate, Environment environment) { + ServicePortSecureResolver servicePortSecureResolver = new ServicePortSecureResolver(properties); + KubernetesNamespaceProvider namespaceProvider = new KubernetesNamespaceProvider(environment); + return new Fabric8CacheableDiscoveryClient(client, properties, servicePortSecureResolver, namespaceProvider, + predicate); + } + @Bean @ConditionalOnSpringCloudKubernetesBlockingDiscoveryHealthInitializer KubernetesDiscoveryClientHealthIndicatorInitializer indicatorInitializer( diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClient.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClient.java index 720eab96fa..896933818f 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClient.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClient.java @@ -16,10 +16,7 @@ package org.springframework.cloud.kubernetes.fabric8.discovery; -import java.util.Objects; - import reactor.core.publisher.Flux; -import reactor.core.scheduler.Schedulers; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; @@ -30,35 +27,30 @@ * * @author Tim Ysewyn */ -final class Fabric8ReactiveDiscoveryClient implements ReactiveDiscoveryClient { - - private final Fabric8DiscoveryClient fabric8DiscoveryClient; +final class Fabric8ReactiveDiscoveryClient extends Fabric8AbstractReactiveDiscoveryClient { Fabric8ReactiveDiscoveryClient(Fabric8DiscoveryClient fabric8DiscoveryClient) { - this.fabric8DiscoveryClient = fabric8DiscoveryClient; + super(fabric8DiscoveryClient); } @Override - public String description() { - return "Fabric8 Kubernetes Reactive Discovery Client"; + public Flux getServices() { + return super.getServices(); } @Override public Flux getInstances(String serviceId) { - Objects.requireNonNull(serviceId, "serviceId must not be null"); - return Flux.defer(() -> Flux.fromIterable(fabric8DiscoveryClient.getInstances(serviceId))) - .subscribeOn(Schedulers.boundedElastic()); + return super.getInstances(serviceId); } @Override - public Flux getServices() { - return Flux.defer(() -> Flux.fromIterable(fabric8DiscoveryClient.getServices())) - .subscribeOn(Schedulers.boundedElastic()); + public String description() { + return "Fabric8 Reactive Discovery Client"; } @Override public int getOrder() { - return fabric8DiscoveryClient.getOrder(); + return super.getOrder(); } } diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfiguration.java b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfiguration.java index 753fcf2d0a..56c6a88da3 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfiguration.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/main/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfiguration.java @@ -34,6 +34,8 @@ import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClientAutoConfiguration; import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider; import org.springframework.cloud.kubernetes.commons.PodUtils; +import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnDiscoveryCacheableReactiveDisabled; +import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnDiscoveryCacheableReactiveEnabled; import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnSpringCloudKubernetesReactiveDiscovery; import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnSpringCloudKubernetesReactiveDiscoveryHealthInitializer; import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryClientHealthIndicatorInitializer; @@ -65,6 +67,7 @@ final class Fabric8ReactiveDiscoveryClientAutoConfiguration { @Bean @ConditionalOnMissingBean + @ConditionalOnDiscoveryCacheableReactiveDisabled Fabric8ReactiveDiscoveryClient fabric8ReactiveDiscoveryClient(KubernetesClient client, KubernetesDiscoveryProperties properties, Predicate predicate, Environment environment) { ServicePortSecureResolver servicePortSecureResolver = new ServicePortSecureResolver(properties); @@ -74,6 +77,18 @@ Fabric8ReactiveDiscoveryClient fabric8ReactiveDiscoveryClient(KubernetesClient c return new Fabric8ReactiveDiscoveryClient(fabric8DiscoveryClient); } + @Bean + @ConditionalOnMissingBean + @ConditionalOnDiscoveryCacheableReactiveEnabled + Fabric8CacheableReactiveDiscoveryClient fabric8CacheableReactiveDiscoveryClient(KubernetesClient client, + KubernetesDiscoveryProperties properties, Predicate predicate, Environment environment) { + ServicePortSecureResolver servicePortSecureResolver = new ServicePortSecureResolver(properties); + KubernetesNamespaceProvider namespaceProvider = new KubernetesNamespaceProvider(environment); + Fabric8DiscoveryClient fabric8DiscoveryClient = new Fabric8DiscoveryClient(client, properties, + servicePortSecureResolver, namespaceProvider, predicate); + return new Fabric8CacheableReactiveDiscoveryClient(fabric8DiscoveryClient); + } + /** * Post an event so that health indicator is initialized. */ diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfigurationApplicationContextTests.java b/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfigurationApplicationContextTests.java index be0ccbac4c..d6dc53d89d 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfigurationApplicationContextTests.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8DiscoveryClientAutoConfigurationApplicationContextTests.java @@ -150,6 +150,56 @@ void reactiveDisabled() { }); } + /** + *
+	 *     - no property related to cacheable in the blocking implementation is set, as such:
+	 *     - Fabric8DiscoveryClient is present
+	 *     - Fabric8CacheableDiscoveryClient is not present
+	 * 
+ */ + @Test + void blockingCacheableDefault() { + setup("spring.main.cloud-platform=KUBERNETES", "spring.cloud.config.enabled=false"); + applicationContextRunner.run(context -> { + assertThat(context).hasSingleBean(Fabric8DiscoveryClient.class); + assertThat(context).doesNotHaveBean(Fabric8CacheableDiscoveryClient.class); + }); + } + + /** + *
+	 *     - cacheable in the blocking implementation = false, as such:
+	 *     - Fabric8DiscoveryClient is present
+	 *     - Fabric8CacheableDiscoveryClient is not present
+	 * 
+ */ + @Test + void blockingCacheableDisabled() { + setup("spring.main.cloud-platform=KUBERNETES", "spring.cloud.config.enabled=false", + "spring.cloud.kubernetes.discovery.cacheable.blocking.enabled=false"); + applicationContextRunner.run(context -> { + assertThat(context).hasSingleBean(Fabric8DiscoveryClient.class); + assertThat(context).doesNotHaveBean(Fabric8CacheableDiscoveryClient.class); + }); + } + + /** + *
+	 *     - cacheable in the blocking implementation = true, as such:
+	 *     - Fabric8DiscoveryClient is not present
+	 *     - Fabric8CacheableDiscoveryClient is present
+	 * 
+ */ + @Test + void blockingCacheableEnabled() { + setup("spring.main.cloud-platform=KUBERNETES", "spring.cloud.config.enabled=false", + "spring.cloud.kubernetes.discovery.cacheable.blocking.enabled=true"); + applicationContextRunner.run(context -> { + assertThat(context).doesNotHaveBean(Fabric8DiscoveryClient.class); + assertThat(context).hasSingleBean(Fabric8CacheableDiscoveryClient.class); + }); + } + private void setup(String... properties) { applicationContextRunner = new ApplicationContextRunner().withConfiguration( AutoConfigurations.of(Fabric8DiscoveryClientAutoConfiguration.class, Fabric8AutoConfiguration.class, diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfigurationApplicationContextTests.java b/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfigurationApplicationContextTests.java index f991e4cdd5..a5397fe4c3 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfigurationApplicationContextTests.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientAutoConfigurationApplicationContextTests.java @@ -142,6 +142,57 @@ void healthEnabledClassNotPresent() { }); } + /** + *
+	 *     - no property related to cacheable in the reactive implementation is set, as such:
+	 *     - Fabric8DiscoveryClient is present
+	 *     - Fabric8CacheableDiscoveryClient is not present
+	 * 
+ */ + @Test + void reactiveCacheableDefault() { + setup("spring.main.cloud-platform=KUBERNETES", "spring.cloud.config.enabled=false"); + applicationContextRunner.run(context -> { + assertThat(context).hasSingleBean(Fabric8ReactiveDiscoveryClient.class); + assertThat(context).doesNotHaveBean(Fabric8CacheableReactiveDiscoveryClient.class); + }); + } + + /** + *
+	 *     - cacheable in the reactive implementation = false, as such:
+	 *     - Fabric8DiscoveryClient is present
+	 *     - Fabric8CacheableDiscoveryClient is not present
+	 * 
+ */ + @Test + void reactiveCacheableDisabled() { + setup("spring.main.cloud-platform=KUBERNETES", "spring.cloud.config.enabled=false", + "spring.cloud.kubernetes.discovery.cacheable.reactive.enabled=false"); + applicationContextRunner.run(context -> { + assertThat(context).hasSingleBean(Fabric8ReactiveDiscoveryClient.class); + assertThat(context).doesNotHaveBean(Fabric8CacheableReactiveDiscoveryClient.class); + }); + } + + /** + *
+	 *     - cacheable in the reactive implementation = true, as such:
+	 *     - Fabric8ReactiveDiscoveryClient is not present
+	 *     - Fabric8CacheableReactiveDiscoveryClient is present
+	 * 
+ */ + @Test + void reactiveCacheableEnabled() { + setup("spring.main.cloud-platform=KUBERNETES", "spring.cloud.config.enabled=false", + "spring.cloud.kubernetes.discovery.cacheable.reactive.enabled=true", + "spring.cloud.discovery.client.health-indicator.enabled=false"); + applicationContextRunner.run(context -> { + assertThat(context).doesNotHaveBean(Fabric8ReactiveDiscoveryClient.class); + assertThat(context).hasSingleBean(Fabric8CacheableReactiveDiscoveryClient.class); + }); + } + private void setup(String... properties) { applicationContextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(UtilAutoConfiguration.class, diff --git a/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientTests.java b/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientTests.java index d99c0f529b..25fd38cbc4 100644 --- a/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientTests.java +++ b/spring-cloud-kubernetes-fabric8-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/discovery/Fabric8ReactiveDiscoveryClientTests.java @@ -87,7 +87,7 @@ void verifyDefaults() { Fabric8DiscoveryClient fabric8DiscoveryClient = new Fabric8DiscoveryClient(kubernetesClient, KubernetesDiscoveryProperties.DEFAULT, SERVICE_PORT_SECURE_RESOLVER, NAMESPACE_PROVIDER, x -> true); ReactiveDiscoveryClient client = new Fabric8ReactiveDiscoveryClient(fabric8DiscoveryClient); - assertThat(client.description()).isEqualTo("Fabric8 Kubernetes Reactive Discovery Client"); + assertThat(client.description()).isEqualTo("Fabric8 Reactive Discovery Client"); assertThat(client.getOrder()).isEqualTo(ReactiveDiscoveryClient.DEFAULT_ORDER); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/discovery/TestAssertions.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/discovery/TestAssertions.java index a7e3fd1241..08e5ce9d56 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/discovery/TestAssertions.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/discovery/TestAssertions.java @@ -43,7 +43,7 @@ */ final class TestAssertions { - private static final String REACTIVE_STATUS = "$.components.reactiveDiscoveryClients.components.['Fabric8 Kubernetes Reactive Discovery Client'].status"; + private static final String REACTIVE_STATUS = "$.components.reactiveDiscoveryClients.components.['Fabric8 Reactive Discovery Client'].status"; private static final String BLOCKING_STATUS = "$.components.discoveryComposite.components.discoveryClient.status"; @@ -179,7 +179,7 @@ static void testReactiveConfiguration(ReactiveDiscoveryClient discoveryClient, C assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(REACTIVE_STATUS).isEqualTo("UP"); assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathArrayValue( - "$.components.reactiveDiscoveryClients.components.['Fabric8 Kubernetes Reactive Discovery Client'].details.services") + "$.components.reactiveDiscoveryClients.components.['Fabric8 Reactive Discovery Client'].details.services") .containsExactlyInAnyOrder("kubernetes", "busybox-service"); assertThat(BASIC_JSON_TESTER.from(healthResult)).doesNotHaveJsonPath(BLOCKING_STATUS);