diff --git a/bom/application/pom.xml b/bom/application/pom.xml index d11b9987818c67..6ca2d3dd93b414 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -5957,6 +5957,11 @@ quarkus-redis-client-deployment ${project.version} + + io.quarkus + quarkus-redis-client-deployment-spi + ${project.version} + io.quarkus quarkus-redis-cache-deployment diff --git a/extensions/redis-cache/deployment/src/main/java/io/quarkus/cache/redis/deployment/RedisCacheProcessor.java b/extensions/redis-cache/deployment/src/main/java/io/quarkus/cache/redis/deployment/RedisCacheProcessor.java index 4de5b1628d3f43..2325b45656a246 100644 --- a/extensions/redis-cache/deployment/src/main/java/io/quarkus/cache/redis/deployment/RedisCacheProcessor.java +++ b/extensions/redis-cache/deployment/src/main/java/io/quarkus/cache/redis/deployment/RedisCacheProcessor.java @@ -34,7 +34,7 @@ import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.redis.deployment.client.RequestedRedisClientBuildItem; +import io.quarkus.redis.deployment.client.spi.RequestedRedisClientBuildItem; import io.quarkus.redis.runtime.client.config.RedisConfig; import io.smallrye.mutiny.Uni; diff --git a/extensions/redis-client/deployment-spi/pom.xml b/extensions/redis-client/deployment-spi/pom.xml new file mode 100644 index 00000000000000..5b6d30e42029de --- /dev/null +++ b/extensions/redis-client/deployment-spi/pom.xml @@ -0,0 +1,26 @@ + + + + quarkus-redis-client-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-redis-client-deployment-spi + Quarkus - Redis Client - Deployment SPI + + + + io.quarkus + quarkus-core-deployment + + + io.quarkus + quarkus-redis-client + + + + diff --git a/extensions/redis-client/deployment-spi/src/main/java/io/quarkus/redis/deployment/client/spi/RedisClientBuildItem.java b/extensions/redis-client/deployment-spi/src/main/java/io/quarkus/redis/deployment/client/spi/RedisClientBuildItem.java new file mode 100644 index 00000000000000..dae9a2d7a64ad5 --- /dev/null +++ b/extensions/redis-client/deployment-spi/src/main/java/io/quarkus/redis/deployment/client/spi/RedisClientBuildItem.java @@ -0,0 +1,27 @@ +package io.quarkus.redis.deployment.client.spi; + +import java.util.function.Supplier; + +import io.quarkus.builder.item.MultiBuildItem; +import io.vertx.mutiny.redis.client.Redis; + +/** + * Provides runtime access to the Redis clients, in the Mutiny variant. + */ +public final class RedisClientBuildItem extends MultiBuildItem { + private final Supplier client; + private final String name; + + public RedisClientBuildItem(Supplier client, String name) { + this.client = client; + this.name = name; + } + + public Supplier getClient() { + return client; + } + + public String getName() { + return name; + } +} diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RequestedRedisClientBuildItem.java b/extensions/redis-client/deployment-spi/src/main/java/io/quarkus/redis/deployment/client/spi/RequestedRedisClientBuildItem.java similarity index 86% rename from extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RequestedRedisClientBuildItem.java rename to extensions/redis-client/deployment-spi/src/main/java/io/quarkus/redis/deployment/client/spi/RequestedRedisClientBuildItem.java index a35af3572769c9..4dc1b3ee5604e2 100644 --- a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RequestedRedisClientBuildItem.java +++ b/extensions/redis-client/deployment-spi/src/main/java/io/quarkus/redis/deployment/client/spi/RequestedRedisClientBuildItem.java @@ -1,4 +1,4 @@ -package io.quarkus.redis.deployment.client; +package io.quarkus.redis.deployment.client.spi; import io.quarkus.builder.item.MultiBuildItem; diff --git a/extensions/redis-client/deployment/pom.xml b/extensions/redis-client/deployment/pom.xml index e18a963cfe2c4e..f267e7df637979 100644 --- a/extensions/redis-client/deployment/pom.xml +++ b/extensions/redis-client/deployment/pom.xml @@ -31,6 +31,10 @@ io.quarkus quarkus-redis-client + + io.quarkus + quarkus-redis-client-deployment-spi + io.quarkus quarkus-smallrye-health-spi diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisClientProcessor.java b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisClientProcessor.java index 55308b824e85d1..bdaeed05a6a538 100644 --- a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisClientProcessor.java +++ b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisClientProcessor.java @@ -48,6 +48,8 @@ import io.quarkus.redis.client.RedisHostsProvider; import io.quarkus.redis.client.RedisOptionsCustomizer; import io.quarkus.redis.client.reactive.ReactiveRedisClient; +import io.quarkus.redis.deployment.client.spi.RedisClientBuildItem; +import io.quarkus.redis.deployment.client.spi.RequestedRedisClientBuildItem; import io.quarkus.redis.runtime.client.RedisClientRecorder; import io.quarkus.redis.runtime.client.config.RedisConfig; import io.quarkus.runtime.LaunchMode; @@ -127,7 +129,8 @@ public void init( VertxBuildItem vertxBuildItem, ApplicationArchivesBuildItem applicationArchivesBuildItem, LaunchModeBuildItem launchMode, BuildProducer nativeImageResources, - BuildProducer hotDeploymentWatchedFiles) { + BuildProducer hotDeploymentWatchedFiles, + BuildProducer clientSuppliers) { // Collect the used redis clients, the unused clients will not be instantiated. Set names = new HashSet<>(); @@ -177,6 +180,9 @@ public void init( .produce(configureAndCreateSyntheticBean(name, RedisClient.class, recorder.getLegacyRedisClient(name))); syntheticBeans.produce(configureAndCreateSyntheticBean(name, ReactiveRedisClient.class, recorder.getLegacyReactiveRedisClient(name))); + + // build items + clientSuppliers.produce(new RedisClientBuildItem(recorder.getRedisClient(name), name)); } recorder.cleanup(shutdown); diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisDatasourceProcessor.java b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisDatasourceProcessor.java index a9c8679b768a25..9944fe65a9ced7 100644 --- a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisDatasourceProcessor.java +++ b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/deployment/client/RedisDatasourceProcessor.java @@ -30,6 +30,7 @@ import io.quarkus.redis.datasource.ReactiveRedisDataSource; import io.quarkus.redis.datasource.RedisDataSource; import io.quarkus.redis.datasource.codecs.Codec; +import io.quarkus.redis.deployment.client.spi.RequestedRedisClientBuildItem; import io.quarkus.redis.runtime.client.RedisClientRecorder; import io.quarkus.vertx.deployment.VertxBuildItem; diff --git a/extensions/redis-client/pom.xml b/extensions/redis-client/pom.xml index 458b2563a75bfe..d3f800372cbdf7 100644 --- a/extensions/redis-client/pom.xml +++ b/extensions/redis-client/pom.xml @@ -18,6 +18,7 @@ deployment + deployment-spi runtime