diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 3474d103d52e6..49e80c3eb98d3 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -5961,6 +5961,11 @@ quarkus-redis-client ${project.version} + + io.quarkus + quarkus-redis-client-runtime-spi + ${project.version} + io.quarkus quarkus-redis-cache @@ -5972,6 +5977,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 4de5b1628d3f4..2325b45656a24 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 0000000000000..236a49220a79c --- /dev/null +++ b/extensions/redis-client/deployment-spi/pom.xml @@ -0,0 +1,30 @@ + + + + quarkus-redis-client-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-redis-client-deployment-spi + Quarkus - Redis Client - Deployment SPI + + + + io.quarkus + quarkus-redis-client-runtime-spi + + + io.quarkus + quarkus-core-deployment + + + io.smallrye.reactive + smallrye-mutiny-vertx-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 0000000000000..dae9a2d7a64ad --- /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 a35af3572769c..4dc1b3ee5604e 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 e18a963cfe2c4..f267e7df63797 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 55308b824e85d..bdaeed05a6a53 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 a9c8679b768a2..9944fe65a9ced 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 458b2563a75bf..c861fb139cc9f 100644 --- a/extensions/redis-client/pom.xml +++ b/extensions/redis-client/pom.xml @@ -18,7 +18,9 @@ deployment + deployment-spi runtime + runtime-spi diff --git a/extensions/redis-client/runtime-spi/pom.xml b/extensions/redis-client/runtime-spi/pom.xml new file mode 100644 index 0000000000000..49ac428649924 --- /dev/null +++ b/extensions/redis-client/runtime-spi/pom.xml @@ -0,0 +1,15 @@ + + + + quarkus-redis-client-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-redis-client-runtime-spi + Quarkus - Redis Client - Runtime SPI + + diff --git a/extensions/redis-client/runtime-spi/src/main/java/io/quarkus/redis/runtime/spi/RedisConstants.java b/extensions/redis-client/runtime-spi/src/main/java/io/quarkus/redis/runtime/spi/RedisConstants.java new file mode 100644 index 0000000000000..d810e83009f32 --- /dev/null +++ b/extensions/redis-client/runtime-spi/src/main/java/io/quarkus/redis/runtime/spi/RedisConstants.java @@ -0,0 +1,7 @@ +package io.quarkus.redis.runtime.spi; + +public class RedisConstants { + public static final String REDIS_CONFIG_ROOT_NAME = "redis"; + public static final String HOSTS_CONFIG_NAME = "hosts"; + public static final String DEFAULT_CLIENT_NAME = ""; +} diff --git a/extensions/redis-client/runtime/pom.xml b/extensions/redis-client/runtime/pom.xml index f00b8e2c6715e..3dd920a374e64 100644 --- a/extensions/redis-client/runtime/pom.xml +++ b/extensions/redis-client/runtime/pom.xml @@ -27,6 +27,10 @@ io.smallrye.reactive smallrye-mutiny-vertx-redis-client + + io.quarkus + quarkus-redis-client-runtime-spi + io.quarkus diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisConfig.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisConfig.java index ac13188c6338b..f6b2171d6c060 100644 --- a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisConfig.java +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisConfig.java @@ -2,6 +2,7 @@ import java.util.Map; +import io.quarkus.redis.runtime.spi.RedisConstants; import io.quarkus.runtime.annotations.ConfigDocMapKey; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; @@ -12,9 +13,9 @@ @ConfigRoot(phase = ConfigPhase.RUN_TIME) public interface RedisConfig { - public final static String REDIS_CONFIG_ROOT_NAME = "redis"; - public final static String HOSTS_CONFIG_NAME = "hosts"; - public static final String DEFAULT_CLIENT_NAME = ""; + public final static String REDIS_CONFIG_ROOT_NAME = RedisConstants.REDIS_CONFIG_ROOT_NAME; + public final static String HOSTS_CONFIG_NAME = RedisConstants.HOSTS_CONFIG_NAME; + public static final String DEFAULT_CLIENT_NAME = RedisConstants.DEFAULT_CLIENT_NAME; /** * The default redis client