Skip to content

Commit

Permalink
Redis Client: add deployment SPI module
Browse files Browse the repository at this point in the history
One build item, `RequestedRedisClientBuildItem`, is moved from the Redis Client
deployment module to the deployment SPI module. This is technically a breaking
change, because it is also moved to a different package, but this build item
doesn't seem to be used anywhere outside of Quarkus, so it should be safe.

Further, one new build item, `RedisClientBuildItem`, is added. It provides
runtime access to the Redis clients (in the Mutiny variant) without having
to perform a CDI lookup.
  • Loading branch information
Ladicek committed Oct 11, 2023
1 parent 31d5e45 commit 1390ebb
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 3 deletions.
5 changes: 5 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5957,6 +5957,11 @@
<artifactId>quarkus-redis-client-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-cache-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
26 changes: 26 additions & 0 deletions extensions/redis-client/deployment-spi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-redis-client-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-redis-client-deployment-spi</artifactId>
<name>Quarkus - Redis Client - Deployment SPI</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -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<Redis> client;
private final String name;

public RedisClientBuildItem(Supplier<Redis> client, String name) {
this.client = client;
this.name = name;
}

public Supplier<Redis> getClient() {
return client;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.redis.deployment.client;
package io.quarkus.redis.deployment.client.spi;

import io.quarkus.builder.item.MultiBuildItem;

Expand Down
4 changes: 4 additions & 0 deletions extensions/redis-client/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,7 +129,8 @@ public void init(
VertxBuildItem vertxBuildItem,
ApplicationArchivesBuildItem applicationArchivesBuildItem, LaunchModeBuildItem launchMode,
BuildProducer<NativeImageResourceBuildItem> nativeImageResources,
BuildProducer<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles) {
BuildProducer<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles,
BuildProducer<RedisClientBuildItem> clientSuppliers) {

// Collect the used redis clients, the unused clients will not be instantiated.
Set<String> names = new HashSet<>();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions extensions/redis-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<modules>
<module>deployment</module>
<module>deployment-spi</module>
<module>runtime</module>
</modules>

Expand Down

0 comments on commit 1390ebb

Please sign in to comment.