-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix 1641 part 3 : make fabric8 discovery client cacheable (3) #2064
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
Fix 1641 part 3 : make fabric8 discovery client cacheable (3) #2064
Conversation
Signed-off-by: wind57 <[email protected]>
…overy-client-cacheable
…overy-client-cacheable
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
| @Documented | ||
| @Inherited | ||
| @Conditional(ConditionalOnDiscoveryCacheableBlockingDisabled.OnDiscoveryCacheableBlockingDisabled.class) | ||
| public @interface ConditionalOnDiscoveryCacheableBlockingDisabled { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
|
@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. |
|
We should add some documentation around this, will that come in a later PR? |
|
yes, documentation will be added as soon as all 3 clients have this option |
Signed-off-by: wind57 <[email protected]>
No description provided.