Skip to content

Commit

Permalink
New Redis API
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier committed Jun 22, 2022
1 parent 37c21c3 commit 3cdeb6e
Show file tree
Hide file tree
Showing 226 changed files with 35,608 additions and 1,311 deletions.
639 changes: 593 additions & 46 deletions docs/src/main/asciidoc/redis-reference.adoc

Large diffs are not rendered by default.

319 changes: 88 additions & 231 deletions docs/src/main/asciidoc/redis.adoc

Large diffs are not rendered by default.

92 changes: 9 additions & 83 deletions extensions/redis-client/deployment/pom.xml
Expand Up @@ -19,6 +19,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devservices-deployment</artifactId>
Expand Down Expand Up @@ -60,6 +64,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -110,88 +119,5 @@
</plugins>
</build>
</profile>
<profile>
<id>docker-redis</id>
<activation>
<property>
<name>start-containers</name>
</property>
</activation>
<properties>
<redis.url>localhost:6379</redis.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>redis:5.0.8-alpine</name>
<alias>quarkus-test-redis</alias>
<run>
<ports>
<port>6379:6379</port>
</ports>
<log>
<prefix>Redis:</prefix>
<date>default</date>
<color>cyan</color>
</log>
<!-- Speed things up a bit by not actually flushing writes to disk -->
<wait>
<!-- good docs found at: http://dmp.fabric8.io/#start-wait -->
<time>5000</time>
<!-- wait until Redis is actually up by checking if we can ping the server-->
<exec>
<postStart>redis-cli PING</postStart>
</exec>
</wait>
</run>
</image>
</images>
<!--Stops all redis images currently running, not just those we just started.
Useful to stop processes still running from a previously failed integration test run -->
<allContainers>true</allContainers>
</configuration>
<executions>
<execution>
<id>docker-start</id>
<phase>compile</phase>
<goals>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>docker-prune</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${docker-prune.location}</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>
</project>
@@ -1,6 +1,5 @@
package io.quarkus.redis.client.deployment;

import static io.quarkus.redis.client.runtime.RedisClientUtil.isDefault;
import static io.quarkus.runtime.LaunchMode.DEVELOPMENT;

import java.io.Closeable;
Expand Down Expand Up @@ -35,8 +34,7 @@
import io.quarkus.devservices.common.ConfigureUtil;
import io.quarkus.devservices.common.ContainerLocator;
import io.quarkus.redis.client.deployment.RedisBuildTimeConfig.DevServiceConfiguration;
import io.quarkus.redis.client.runtime.RedisClientUtil;
import io.quarkus.redis.client.runtime.RedisConfig;
import io.quarkus.redis.client.runtime.config.RedisConfig;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigUtils;

Expand Down Expand Up @@ -71,7 +69,7 @@ public List<DevServicesResultBuildItem> startRedisContainers(LaunchModeBuildItem
GlobalDevServicesConfig devServicesConfig) {

Map<String, DevServiceConfiguration> currentDevServicesConfiguration = new HashMap<>(config.additionalDevServices);
currentDevServicesConfiguration.put(RedisClientUtil.DEFAULT_CLIENT, config.defaultDevService);
currentDevServicesConfiguration.put(RedisConfig.DEFAULT_CLIENT_NAME, config.defaultDevService);

// figure out if we need to shut down and restart existing redis containers
// if not and the redis containers have already started we just return
Expand Down Expand Up @@ -145,28 +143,28 @@ public List<DevServicesResultBuildItem> startRedisContainers(LaunchModeBuildItem
return devServices.stream().map(RunningDevService::toBuildItem).collect(Collectors.toList());
}

private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuildItem, String connectionName,
private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuildItem, String name,
DevServicesConfig devServicesConfig, LaunchMode launchMode,
boolean useSharedNetwork, Optional<Duration> timeout) {
if (!devServicesConfig.enabled) {
// explicitly disabled
log.debug("Not starting devservices for " + (isDefault(connectionName) ? "default redis client" : connectionName)
log.debug("Not starting devservices for " + (RedisConfig.isDefaultClient(name) ? "default redis client" : name)
+ " as it has been disabled in the config");
return null;
}

String configPrefix = getConfigPrefix(connectionName);
String configPrefix = getConfigPrefix(name);

boolean needToStart = !ConfigUtils.isPropertyPresent(configPrefix + RedisConfig.HOSTS_CONFIG_NAME);
if (!needToStart) {
log.debug("Not starting devservices for " + (isDefault(connectionName) ? "default redis client" : connectionName)
log.debug("Not starting devservices for " + (RedisConfig.isDefaultClient(name) ? "default redis client" : name)
+ " as hosts have been provided");
return null;
}

if (!dockerStatusBuildItem.isDockerAvailable()) {
log.warn("Please configure quarkus.redis.hosts for "
+ (isDefault(connectionName) ? "default redis client" : connectionName)
+ (RedisConfig.isDefaultClient(name) ? "default redis client" : name)
+ " or get a working docker instance");
return null;
}
Expand All @@ -193,10 +191,10 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild
.orElseGet(defaultRedisServerSupplier);
}

private String getConfigPrefix(String connectionName) {
private String getConfigPrefix(String name) {
String configPrefix = QUARKUS + RedisConfig.REDIS_CONFIG_ROOT_NAME + DOT;
if (!isDefault(connectionName)) {
configPrefix = configPrefix + connectionName + DOT;
if (!RedisConfig.isDefaultClient(name)) {
configPrefix = configPrefix + name + DOT;
}
return configPrefix;
}
Expand Down

0 comments on commit 3cdeb6e

Please sign in to comment.