Skip to content

Conversation

@wind57
Copy link
Contributor

@wind57 wind57 commented Oct 11, 2025

No description provided.

Signed-off-by: wind57 <[email protected]>
@wind57 wind57 changed the title Fix 1641 part 2 : make fabric8 discovery client cacheable Fix 1641 part 3 : make fabric8 discovery client cacheable (3) Oct 12, 2025
@Documented
@Inherited
@Conditional(ConditionalOnDiscoveryCacheableBlockingDisabled.OnDiscoveryCacheableBlockingDisabled.class)
public @interface ConditionalOnDiscoveryCacheableBlockingDisabled {
Copy link
Contributor Author

@wind57 wind57 Oct 12, 2025

Choose a reason for hiding this comment

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

introduce 4 new conditionals (2 for blocking, 2 for reactive), to let users have the option to select a cacheable or a non-cacheable discovery client. The default one is non-cacheable.

/**
* @author wind57
*/
abstract class Fabric8AbstractBlockingDiscoveryClient implements DiscoveryClient {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all the existing code AS-IS, from the DiscoveryClient has moved in here, without any kind of changes. Now both cacheable and non-cacheable discovery clients extend it.

}

@Override
@Cacheable("fabric8-blocking-discovery-services")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cacheable services and instances for the blocking discovery client

}

@Override
@Cacheable("fabric8-reactive-discovery-instances")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cacheable reactive discovery client

private final KubernetesNamespaceProvider namespaceProvider;

private final Predicate<Service> predicate;
final class Fabric8DiscoveryClient extends Fabric8AbstractBlockingDiscoveryClient {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this client does not change at all, it just delegates the calls now, but its exactly the same code

Copy link
Contributor

Choose a reason for hiding this comment

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

Why override these methods just to call super?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because both cacheable and non-cacheable implementations delegate to the same super, so they do the exact thing, with the difference that one is cacheable capable, and one is not

Copy link
Contributor

Choose a reason for hiding this comment

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

Right but in the non-cachable versions where we don't have to add the @Cachable annotation, why do we need to override these methods in the class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OMG! you're right! thank you :)


@Bean
@ConditionalOnMissingBean
@ConditionalOnDiscoveryCacheableBlockingDisabled
Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can now select cacheable or non-cacheable discovery client


Fabric8ReactiveDiscoveryClient(Fabric8DiscoveryClient fabric8DiscoveryClient) {
this.fabric8DiscoveryClient = fabric8DiscoveryClient;
super(fabric8DiscoveryClient);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as for the blocking implementation, the logic does not change at all here, it just delegates

@Bean
@ConditionalOnMissingBean
@ConditionalOnDiscoveryCacheableReactiveEnabled
Fabric8CacheableReactiveDiscoveryClient fabric8CacheableReactiveDiscoveryClient(KubernetesClient client,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reactive clients now can also be cacheable or non-cacheable

@wind57 wind57 marked this pull request as ready for review October 12, 2025 19:01
@wind57
Copy link
Contributor Author

wind57 commented Oct 12, 2025

@ryanjbaxter this starts to add cacheable discovery clients. First we do it for fabric8, have PRs in motion for the rest too. Ready to look at now.

@ryanjbaxter
Copy link
Contributor

We should add some documentation around this, will that come in a later PR?

@wind57
Copy link
Contributor Author

wind57 commented Oct 12, 2025

yes, documentation will be added as soon as all 3 clients have this option

@wind57 wind57 requested a review from ryanjbaxter October 12, 2025 20:33
Signed-off-by: wind57 <[email protected]>
@ryanjbaxter ryanjbaxter merged commit e0f267c into spring-cloud:main Oct 12, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

KubernetesReactiveDiscoveryClient cache configuration issues

3 participants