Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate constructor that uses namespace #1285

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
032014e
test
wind57 Dec 4, 2021
c3d0ad2
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Dec 13, 2021
10889fd
fix @Nested tests not running
wind57 Dec 16, 2021
8f0375a
merged main
wind57 Dec 17, 2021
96ebf42
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Jan 5, 2022
db8403e
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Jan 12, 2022
90a5345
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Jan 12, 2022
b041c00
trigger again
wind57 Jan 13, 2022
9580444
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 15, 2022
a34ac47
Add renovate.json
renovate[bot] Jul 13, 2022
6613f78
Merge branch 'spring-cloud:main' into main
wind57 Jul 13, 2022
1b3eae9
Merge pull request #1 from wind57/renovate/configure
wind57 Jul 13, 2022
4275382
Merge branch 'spring-cloud:main' into main
wind57 Mar 13, 2023
618f25a
Delete renovate.json
wind57 Mar 14, 2023
100a9cd
Delete delme.sh
wind57 Mar 14, 2023
4b9056b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 14, 2023
315a85b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 15, 2023
ed3c264
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 15, 2023
446d630
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 16, 2023
6821a28
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 16, 2023
9e95a8a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 16, 2023
02840b1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 16, 2023
7e31d65
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 20, 2023
926f4d7
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 20, 2023
344e1d4
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 21, 2023
e91ac12
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 23, 2023
ba6e088
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Mar 28, 2023
49025e8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Apr 1, 2023
a647bb3
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Apr 4, 2023
16b09ab
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Apr 4, 2023
c8d8a72
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Apr 5, 2023
30436b5
fix
wind57 Apr 5, 2023
8c1a4ee
checkstyle
wind57 Apr 5, 2023
591f340
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Apr 6, 2023
c331bd0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 Apr 6, 2023
f4755d5
Merge branch 'main' into deprecate-constructor-that-uses-namespace
wind57 Apr 6, 2023
248c30a
review comments fixes
wind57 Apr 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.cloud.kubernetes.client.discovery.reactive;

import java.util.Objects;

import io.kubernetes.client.informer.SharedInformer;
import io.kubernetes.client.informer.SharedInformerFactory;
import io.kubernetes.client.informer.cache.Lister;
Expand All @@ -29,7 +31,6 @@
import org.springframework.cloud.kubernetes.client.discovery.KubernetesInformerDiscoveryClient;
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
import org.springframework.util.Assert;

/**
* @author Ryan Baxter
Expand All @@ -38,6 +39,7 @@ public class KubernetesInformerReactiveDiscoveryClient implements ReactiveDiscov

private final KubernetesInformerDiscoveryClient kubernetesDiscoveryClient;

@Deprecated(forRemoval = true)
public KubernetesInformerReactiveDiscoveryClient(KubernetesNamespaceProvider kubernetesNamespaceProvider,
SharedInformerFactory sharedInformerFactory, Lister<V1Service> serviceLister,
Lister<V1Endpoints> endpointsLister, SharedInformer<V1Service> serviceInformer,
Expand All @@ -47,14 +49,23 @@ public KubernetesInformerReactiveDiscoveryClient(KubernetesNamespaceProvider kub
serviceInformer, endpointsInformer, properties);
}

KubernetesInformerReactiveDiscoveryClient(
SharedInformerFactory sharedInformerFactory, Lister<V1Service> serviceLister,
Lister<V1Endpoints> endpointsLister, SharedInformer<V1Service> serviceInformer,
SharedInformer<V1Endpoints> endpointsInformer, KubernetesDiscoveryProperties properties) {
this.kubernetesDiscoveryClient = new KubernetesInformerDiscoveryClient(
sharedInformerFactory, serviceLister, endpointsLister,
serviceInformer, endpointsInformer, properties);
}

@Override
public String description() {
return "Kubernetes Reactive Discovery Client";
}

@Override
public Flux<ServiceInstance> getInstances(String serviceId) {
Assert.notNull(serviceId, "[Assertion failed] - the object argument must not be null");
Objects.requireNonNull(serviceId, "serviceId must be provided");
return Flux.defer(() -> Flux.fromIterable(kubernetesDiscoveryClient.getInstances(serviceId)))
.subscribeOn(Schedulers.boundedElastic());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public ReactiveDiscoveryClientHealthIndicator kubernetesReactiveDiscoveryClientH
return healthIndicator;
}

@Deprecated(forRemoval = true)
@Bean
@ConditionalOnMissingBean
public KubernetesInformerReactiveDiscoveryClient kubernetesReactiveDiscoveryClient(
Expand All @@ -85,4 +86,15 @@ public KubernetesInformerReactiveDiscoveryClient kubernetesReactiveDiscoveryClie
serviceLister, endpointsLister, serviceInformer, endpointsInformer, properties);
}

@Bean
@ConditionalOnMissingBean
KubernetesInformerReactiveDiscoveryClient kubernetesClientReactiveDiscoveryClient(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldnt be creating 2 bean instances, we can remove the @Bean annotation above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's @ConditionalOnMissingBean on both of them, so only one will be created. We don't care which one will be created at this point in time, because they do the same thing in their constructors.

Later, in the next major release, I will have a PR that drops all of these deprecations.

Btw, the same situation exists in KubernetesInformerDiscoveryClientAutoConfiguration (the non-reactive auto-configuration).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better now that I think about your suggestion is to remove the @Bean in both reactive and non-reactive auto-configurations. This is one nice piece of advice, thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly

SharedInformerFactory sharedInformerFactory,
Lister<V1Service> serviceLister, Lister<V1Endpoints> endpointsLister,
SharedInformer<V1Service> serviceInformer, SharedInformer<V1Endpoints> endpointsInformer,
KubernetesDiscoveryProperties properties) {
return new KubernetesInformerReactiveDiscoveryClient(sharedInformerFactory,
serviceLister, endpointsLister, serviceInformer, endpointsInformer, properties);
}

}