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

Introduce build time flag property to disable the cache extension #11139

Conversation

gwenneg
Copy link
Member

@gwenneg gwenneg commented Jul 31, 2020

Fixes #11138.

@@ -113,4 +114,13 @@ void recordCachesBuild(CombinedIndexBuildItem combinedIndex, BeanContainerBuildI
}
return cacheNames;
}

private static class IsEnabled implements BooleanSupplier {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick: Can we call give this a more descriptive name, something like CacheEnabled or something?
That would make it more consistent with the the existing uses of onlyIf

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, I just applied your suggestion. Thanks for reviewing this!

@gwenneg gwenneg force-pushed the issue-11138-cache-extension-enable-flag-property branch from c4d5226 to d7d3b91 Compare August 1, 2020 19:13
@jaikiran
Copy link
Member

jaikiran commented Aug 3, 2020

Hello @gwenneg, if this config set to "disable this extension", then would adding this extension to the application's dependency (pom.xml for example) be of any value? In other words, can't the extension be disabled by just removing it from the application's dependency?

@geoand
Copy link
Contributor

geoand commented Aug 3, 2020

@jaikiran this kind of configuration usually proves helpful in testing scenarios

@jaikiran
Copy link
Member

jaikiran commented Aug 3, 2020

@jaikiran this kind of configuration usually proves helpful in testing scenarios

Hello @geoand, on the other hand, wouldn't this mean that every single build step method of every build step processor that corresponds to this extension will now have to add:

    @BuildStep(onlyIf = CacheEnabled.class)

Perhaps, if we do need something like this, maybe this should be some generic config which can then be implemented in the build step processor invocation layer where with a single check it can decide if the processor and its build steps are relevant or not depending on that enabled/disabled config?

@geoand
Copy link
Contributor

geoand commented Aug 3, 2020

Interesting idea @jaikiran.

Are you thinking something @BuildStep(onlyIfProperty ="some.value")?

@gwenneg
Copy link
Member Author

gwenneg commented Aug 3, 2020

Hello @gwenneg, if this config set to "disable this extension", then would adding this extension to the application's dependency (pom.xml for example) be of any value? In other words, can't the extension be disabled by just removing it from the application's dependency?

This PR started from a Quarkus user who needed to disable the extension temporarily for testing purposes. This cannot be done by removing the extension from the application pom.xml since it would also mean that all caching annotations must be removed from the source code.

@gwenneg
Copy link
Member Author

gwenneg commented Aug 3, 2020

@jaikiran this kind of configuration usually proves helpful in testing scenarios

Hello @geoand, on the other hand, wouldn't this mean that every single build step method of every build step processor that corresponds to this extension will now have to add:

    @BuildStep(onlyIf = CacheEnabled.class)

Perhaps, if we do need something like this, maybe this should be some generic config which can then be implemented in the build step processor invocation layer where with a single check it can decide if the processor and its build steps are relevant or not depending on that enabled/disabled config?

For this specific case, I didn't disable all build steps. The one providing the FeatureBuildItem instance is still active since the extension is still part of the application (even if it is disabled). Also, when the programmatic API of this extension will be there, some other build steps will certainly remain active while the annotations caching API might be disabled.

@gwenneg
Copy link
Member Author

gwenneg commented Aug 3, 2020

@geoand Now that I wrote the previous comment, I am wondering if the property included in this PR should contain a part indicating that it will disable the annotations only... Something like quarkus.cache.annotations.enabled or quarkus.cache.annotation-api.enabled.

@geoand
Copy link
Contributor

geoand commented Aug 3, 2020

@gwenneg I don't think that is necessary. Maybe just update the javadoc of the property to mention that the caching annotations will have no effect

@gwenneg gwenneg force-pushed the issue-11138-cache-extension-enable-flag-property branch from d7d3b91 to 0bdeeb5 Compare August 3, 2020 12:28
@gwenneg gwenneg force-pushed the issue-11138-cache-extension-enable-flag-property branch from 0bdeeb5 to 8eeafbc Compare August 3, 2020 12:31
@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 3, 2020
@geoand geoand added this to the 1.8.0 - master milestone Aug 3, 2020
@gwenneg
Copy link
Member Author

gwenneg commented Aug 3, 2020

@geoand I did a small CacheConfig Javadoc update to include your suggestion.

@geoand
Copy link
Contributor

geoand commented Aug 3, 2020

Looks good, thanks!

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I'm a bit torn on that one as I wonder if it would not make more sense to just disable the interceptors and keep the rest of the logic running.

But maybe it could be an issue if it was using an external cache service which we might support at some point.

Merging anyway.

@gsmet gsmet merged commit 1a54332 into quarkusio:master Aug 4, 2020
@gwenneg gwenneg deleted the issue-11138-cache-extension-enable-flag-property branch August 4, 2020 11:47
@gwenneg
Copy link
Member Author

gwenneg commented Aug 4, 2020

@gsmet I also hesitated between disabling the entire extension logic at build time or disabling the interceptors logic only at run time. But since this PR started from a user who wanted to compare performances with and without the cache extension, disabling it at build time seemed more relevant to me. Anyway, this could easily be changed in the future.

Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cache triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce build time flag property to disable the cache extension
4 participants