-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve errors when #cache is used but can't work
- Loading branch information
Showing
3 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ns/qute/runtime/src/main/java/io/quarkus/qute/runtime/cache/MissingCacheConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.qute.runtime.cache; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
import java.util.function.Function; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
|
||
import io.quarkus.qute.CacheSectionHelper; | ||
import io.quarkus.qute.EngineBuilder; | ||
import io.quarkus.qute.ResultNode; | ||
|
||
public class MissingCacheConfigurator { | ||
|
||
void configureEngine(@Observes EngineBuilder builder) { | ||
builder.addSectionHelper(new CacheSectionHelper.Factory(new CacheSectionHelper.Cache() { | ||
|
||
@Override | ||
public CompletionStage<ResultNode> getValue(String key, Function<String, CompletionStage<ResultNode>> loader) { | ||
throw new IllegalStateException("#cache cannot be used without the 'quarkus-cache' extension"); | ||
} | ||
})); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ntime/src/main/java/io/quarkus/qute/runtime/cache/UnsupportedRemoteCacheConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.qute.runtime.cache; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
import java.util.function.Function; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
|
||
import io.quarkus.qute.CacheSectionHelper; | ||
import io.quarkus.qute.EngineBuilder; | ||
import io.quarkus.qute.ResultNode; | ||
|
||
public class UnsupportedRemoteCacheConfigurator { | ||
|
||
void configureEngine(@Observes EngineBuilder builder) { | ||
builder.addSectionHelper(new CacheSectionHelper.Factory(new CacheSectionHelper.Cache() { | ||
|
||
@Override | ||
public CompletionStage<ResultNode> getValue(String key, Function<String, CompletionStage<ResultNode>> loader) { | ||
throw new IllegalStateException("#cache is not supported for remote caches"); | ||
} | ||
})); | ||
} | ||
|
||
} |