diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index dea2070daacbe..feb780a4dc917 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -287,3 +287,6 @@ labelPRBasedOnFilePath: - integration-tests/vertx/**/* - integration-tests/vertx-graphql/**/* - integration-tests/vertx-http/**/* + area/redis: + - extensions/redis-client/**/* + - integration-tests/redis-client/**/* \ No newline at end of file diff --git a/.github/workflows/ci-actions.yml b/.github/workflows/ci-actions.yml index 693cd9b57808b..50f1db9fdb5be 100644 --- a/.github/workflows/ci-actions.yml +++ b/.github/workflows/ci-actions.yml @@ -36,8 +36,8 @@ on: env: # Workaround testsuite locale issue LANG: en_US.UTF-8 - NATIVE_TEST_MAVEN_OPTS: "-B --settings .github/mvn-settings.xml --fail-at-end -Dquarkus.native.container-build=true -Dtest-postgresql -Dtest-elasticsearch -Dtest-keycloak -Dtest-amazon-services -Dtest-db2 -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dnative-image.xmx=5g -Dnative -Dformat.skip install" - JVM_TEST_MAVEN_OPTS: "-e -B --settings .github/mvn-settings.xml -Dtest-postgresql -Dtest-elasticsearch -Dtest-db2 -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dtest-keycloak -Dformat.skip" + NATIVE_TEST_MAVEN_OPTS: "-B --settings .github/mvn-settings.xml --fail-at-end -Dquarkus.native.container-build=true -Dtest-postgresql -Dtest-elasticsearch -Dtest-keycloak -Dtest-amazon-services -Dtest-db2 -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dtest-redis -Dnative-image.xmx=5g -Dnative -Dformat.skip install" + JVM_TEST_MAVEN_OPTS: "-e -B --settings .github/mvn-settings.xml -Dtest-postgresql -Dtest-elasticsearch -Dtest-db2 -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dtest-keycloak -Dtest-redis -Dformat.skip" DB_USER: hibernate_orm_test DB_PASSWORD: hibernate_orm_test DB_NAME: hibernate_orm_test @@ -72,7 +72,7 @@ jobs: - name: Compute cache restore key # Always recompute on a push so that the maven repo doesnt grow indefinitely with old versions run: | - if ${{ github.event_name == 'pull_request' }}; then echo "::set-env name=COMPUTED_RESTORE_KEY::q2maven-"; fi + if ${{ github.event_name == 'pull_request' }}; then echo "::set-env name=COMPUTED_RESTORE_KEY::q2maven-"; fi - name: Cache Maven Repository id: cache-maven uses: n1hility/cache@v2 @@ -164,7 +164,7 @@ jobs: image: neo4j/neo4j-experimental:4.0.0-rc01 env: NEO4J_AUTH: neo4j/secret - NEO4J_dbms_memory_pagecache_size: 10M + NEO4J_dbms_memory_pagecache_size: 10M NEO4J_dbms_memory_heap_initial__size: 10M ports: - 127.0.0.1:7687:7687 @@ -180,7 +180,10 @@ jobs: - 127.0.0.1:8010:4576 - 127.0.0.1:8011:4599 - 127.0.0.1:8012:4566 - + redis: + image: redis:5.0.8-alpine + ports: + - 127.0.0.1:6379:6379 steps: - name: Start mysql shell: bash @@ -285,7 +288,7 @@ jobs: timeout-minutes: 180 env: MAVEN_OPTS: -Xmx1408m - + steps: - uses: actions/checkout@v2 - name: Set up JDK 11 @@ -385,7 +388,7 @@ jobs: with: name: test-reports-tcks path: 'test-reports.tgz' - + native-tests: name: Native Tests - ${{matrix.category}} needs: build-jdk11 @@ -436,10 +439,12 @@ jobs: liquibase - category: Data4 neo4j: "true" - timeout: 50 + redis: "true" + timeout: 55 test-modules: > mongodb-client mongodb-panache + redis-client neo4j hibernate-orm-rest-data-panache - category: Data5 @@ -559,9 +564,9 @@ jobs: # These should be services, but services do not (yet) allow conditional execution - name: Postgres Service run: | - docker run --rm --publish 5432:5432 --name build-postgres \ - -e POSTGRES_USER=$DB_USER -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_DB=$DB_NAME \ - -d postgres:10.5 + docker run --rm --publish 5432:5432 --name build-postgres \ + -e POSTGRES_USER=$DB_USER -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_DB=$DB_NAME \ + -d postgres:10.5 if: matrix.postgres - name: MySQL Service run: | @@ -599,6 +604,9 @@ jobs: -e NEO4J_AUTH=neo4j/secret -e NEO4J_dbms_memory_pagecache_size=10M -e NEO4J_dbms_memory_heap_initial__size=10M \ -d neo4j/neo4j-experimental:4.0.0-rc01 if: matrix.neo4j + - name: Redis Service + run: docker run --rm --publish 6379:6379 --name build-redis -d redis:5.0.8-alpine + if: matrix.redis - name: Keycloak Service run: | docker run --rm --publish 8180:8080 --publish 8543:8443 --name build-keycloak \ @@ -625,7 +633,7 @@ jobs: shell: bash run: tar -xzf maven-repo.tgz -C ~ - name: Build with Maven - env: + env: TEST_MODULES: ${{matrix.test-modules}} CATEGORY: ${{matrix.category}} run: | diff --git a/bom/deployment/pom.xml b/bom/deployment/pom.xml index fbb3c8d247c99..401f1425aca3a 100644 --- a/bom/deployment/pom.xml +++ b/bom/deployment/pom.xml @@ -1,7 +1,7 @@ + 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"> quarkus-parent io.quarkus @@ -17,10 +17,10 @@ - + diff --git a/bom/runtime/pom.xml b/bom/runtime/pom.xml index 5836fb654cf7a..dfc215b07eaf0 100644 --- a/bom/runtime/pom.xml +++ b/bom/runtime/pom.xml @@ -3496,6 +3496,11 @@ smallrye-mutiny-vertx-mail-client ${mutiny-client.version} + + io.smallrye.reactive + smallrye-mutiny-vertx-redis-client + ${mutiny-client.version} + io.vertx vertx-rx-java2 @@ -4100,6 +4105,18 @@ ${project.version} + + io.quarkus + quarkus-redis-client + ${project.version} + + + + io.quarkus + quarkus-redis-client-deployment + ${project.version} + + io.quarkus.qute diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Feature.java b/core/deployment/src/main/java/io/quarkus/deployment/Feature.java index d78efb58b7c0a..e5d72a45e5f14 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/Feature.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/Feature.java @@ -66,6 +66,7 @@ public enum Feature { OIDC, PICOCLI, QUTE, + REDIS_CLIENT, RESTEASY, RESTEASY_JACKSON, RESTEASY_JAXB, @@ -114,8 +115,7 @@ public enum Feature { VERTX, VERTX_WEB, VERTX_GRAPHQL, - WEBJARS_LOCATOR, - ; + WEBJARS_LOCATOR; public String getName() { return toString().toLowerCase().replace("_", "-"); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java index 432c86f9ad70f..59f2b16314ad4 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java @@ -29,11 +29,11 @@ public FeatureBuildItem(String name) { /** * The name that gets displayed in the log. - * + * * @return the name */ public String getName() { return name; } -} +} \ No newline at end of file diff --git a/docs/src/main/asciidoc/index.adoc b/docs/src/main/asciidoc/index.adoc index 2f5b7e4a2fa13..f706030f1b7e3 100644 --- a/docs/src/main/asciidoc/index.adoc +++ b/docs/src/main/asciidoc/index.adoc @@ -64,6 +64,7 @@ include::quarkus-intro.adoc[tag=intro] * link:command-mode-reference.html[Command Mode Applications] * link:grpc.html[Using gRPC] * link:picocli.html[Command Mode with Picocli] +* link:redis.html[Connecting to Redis] * link:faq.html[FAQs] diff --git a/docs/src/main/asciidoc/native-and-ssl.adoc b/docs/src/main/asciidoc/native-and-ssl.adoc index 50f3c600a0e20..8786b2d3f2680 100644 --- a/docs/src/main/asciidoc/native-and-ssl.adoc +++ b/docs/src/main/asciidoc/native-and-ssl.adoc @@ -74,6 +74,7 @@ As SSL is de facto the standard nowadays, we decided to enable its support autom * the Keycloak extension (`quarkus-keycloak`), * the Kubernetes client extension (`quarkus-kubernetes-client`), * the Mailer extension (`quarkus-mailer`), + * the Redis client extension (`quarkus-redis-client`), * the MongoDB extension (`quarkus-mongodb-client`), * the Neo4j extension (`quarkus-neo4j`), * the OAuth2 extension (`quarkus-elytron-security-oauth2`), diff --git a/docs/src/main/asciidoc/redis.adoc b/docs/src/main/asciidoc/redis.adoc new file mode 100644 index 0000000000000..4d33438cc4964 --- /dev/null +++ b/docs/src/main/asciidoc/redis.adoc @@ -0,0 +1,549 @@ +//// +This guide is maintained in the main Quarkus repository +and pull requests should be submitted there: +https://github.com/quarkusio/quarkus/tree/master/docs/src/main/asciidoc +//// += Quarkus - Using the Redis Client +:extension-status: preview +include::./attributes.adoc[] + +This guide demonstrates how your Quarkus application can connect to a Redis server using the Redis Client extension. + +include::./status-include.adoc[] + +== Prerequisites + +To complete this guide, you need: + +* less than 15 minutes +* an IDE +* JDK 1.8+ installed with `JAVA_HOME` configured appropriately +* Apache Maven 3.5.3+ +* A running Redis server, or Docker Compose to start one +* GraalVM installed if you want to run in native mode. + +== Architecture + +In this guide, we are going to expose a simple Rest API to increment numbers by using the https://redis.io/commands/incrby[`INCRBY`] command. +Along the way, we'll see how to use other Redis commands like `GET`, `SET`, `DEL` and `KEYS`. + +We'll be using the Quarkus Redis Client extension to connect to our Redis Server. The extension is implemented on top of the https://vertx.io/docs/vertx-redis-client/java/[Vert.x Redis Client], +providing an asynchronous and non-blocking way to connect to Redis. + +== Solution + +We recommend that you follow the instructions in the next sections and create the application step by step. +However, you can go right to the completed example. + +Clone the Git repository: `git clone {quickstarts-clone-url}`, or download an {quickstarts-archive-url}[archive]. + +The solution is located in the `redis-quickstart` {quickstarts-tree-url}/redis-quickstart[directory]. + +== Creating the Maven Project + +First, we need a new project. Create a new project with the following command: + +[source, subs=attributes+] +---- +mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ + -DprojectGroupId=org.acme \ + -DprojectArtifactId=redis-quickstart \ + -Dextensions="redis-client, resteasy-jsonb, resteasy-mutiny" +cd redis-quickstart +---- + +This command generates a Maven project, importing the Redis extension. + + +If you already have your Quarkus project configured, you can add the `redis-client` extension +to your project by running the following command in your project base directory: + +[source,bash] +---- +./mvnw quarkus:add-extension -Dextensions="redis-client" +---- + +This will add the following to your `pom.xml`: + +[source,xml] +---- + + io.quarkus + quarkus-redis-client + +---- + + +== Starting the Redis server + +Then, we need to start a Redis instance (if you do not have one already) using the following command: + +[source, bash] +---- +docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name redis_quarkus_test -p 6379:6379 redis:5.0.6 +---- + +== Configuring Redis properties + +Once we have the Redis server running, we need to configure the Redis connection properties. +This is done in the `application.properties` configuration file. Edit it to the following content: + +[source] +---- +quarkus.redis.hosts=localhost:6379 <1> +---- + +1. Configure Redis hosts to connect to. Here we connect to the Redis server we started in the previous section + +== Creating the Increment POJO + +We are going to model our increments using the `Increment` POJO. +Create the `src/main/java/org/acme/redis/Increment.java` file, with the following content: + +[source, java] +---- +package org.acme.redis; + +public class Increment { + public String key; // <1> + public int value; // <2> + + public Increment(String key, int value) { + this.key = key; + this.value = value; + } + + public Increment() { + } +} +---- + +1. The key that will be used as the Redis key +2. The value held by the Redis key + + +== Creating the Increment Service + +We are going to create an `IncrementService` class which will play the role of a Redis client. +With this class, we'll be able to perform the `SET`, `GET` , `DELET`, `KEYS` and `INCRBY` Redis commands. + +Create the `src/main/java/org/acme/redis/IncrementService.java` file, with the following content: + +[source, java] +---- +package org.acme.redis; + +import io.quarkus.redis.client.RedisClient; +import io.quarkus.redis.client.reactive.ReactiveRedisClient; +import io.smallrye.mutiny.Uni; + +import io.vertx.mutiny.redis.client.Response; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +class IncrementService { + + @Inject + RedisClient redisClient; // <1> + + @Inject + ReactiveRedisClient reactiveRedisClient; // <2> + + Uni del(String key) { + return reactiveRedisClient.del(Arrays.asList(key)) + .map(response -> null); + } + + String get(String key) { + return redisClient.get(key).toString(); + } + + void set(String key, Integer value) { + redisClient.set(Arrays.asList(key, value.toString())); + } + + void increment(String key, Integer incrementBy) { + redisClient.incrby(key, incrementBy.toString()); + } + + Uni> keys() { + return reactiveRedisClient + .keys("*") + .map(response -> { + List result = new ArrayList<>(); + for (Response r : response) { + result.add(r.toString()); + } + return result; + }); + } +} +---- +1. Inject the Redis synchronous client +2. Inject the Reactive Redis client + +== Creating the Increment Resource + +Create the `src/main/java/org/acme/redis/IncrementResource.java` file, with the following content: + +[source, java] +---- +package org.acme.redis; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.PathParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; +import javax.ws.rs.Path; +import javax.ws.rs.POST; +import javax.ws.rs.DELETE; +import javax.ws.rs.core.MediaType; +import java.util.List; + +import io.smallrye.mutiny.Uni; + +@Path("/increments") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class IncrementResource { + + @Inject + IncrementService service; + + @GET + public Uni> keys() { + return service.keys(); + } + + @POST + public Increment create(Increment increment) { + service.set(increment.key, increment.value); + return increment; + } + + @GET + @Path("/{key}") + public Increment get(@PathParam("key") String key) { + return new Increment(key, Integer.valueOf(service.get(key))); + } + + @PUT + @Path("/{key}") + public void increment(@PathParam("key") String key, Integer value) { + service.increment(key, value); + } + + @DELETE + @Path("/{key}") + public Uni delete(@PathParam("key") String key) { + return service.del(key); + } +} +---- + +== Modifying the test class + +Edit the `src/test/java/org/acme/redis/IncrementResourceTest.java` file to the following content: + +[source, java] +---- +package org.acme.redis; + +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +import static io.restassured.RestAssured.given; + +import io.restassured.http.ContentType; + +@QuarkusTest +public class IncrementResourceTest { + + @Test + public void testRedisOperations() { + // verify that we have nothing + given() + .accept(ContentType.JSON) + .when() + .get("/increments") + .then() + .statusCode(200) + .body("size()", is(0)); + + // create a first increment key with an initial value of 0 + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"key\":\"first-key\",\"value\":0}") + .when() + .post("/increments") + .then() + .statusCode(200) + .body("key", is("first-key")) + .body("value", is(0)); + + // create a second increment key with an initial value of 10 + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"key\":\"second-key\",\"value\":10}") + .when() + .post("/increments") + .then() + .statusCode(200) + .body("key", is("second-key")) + .body("value", is(10)); + + // increment first key by 1 + given() + .contentType(ContentType.JSON) + .body("1") + .when() + .put("/increments/first-key") + .then() + .statusCode(204); + + // verify that key has been incremented + given() + .accept(ContentType.JSON) + .when() + .get("/increments/first-key") + .then() + .statusCode(200) + .body("key", is("first-key")) + .body("value", is(1)); + + // increment second key by 1000 + given() + .contentType(ContentType.JSON) + .body("1000") + .when() + .put("/increments/second-key") + .then() + .statusCode(204); + + // verify that key has been incremented + given() + .accept(ContentType.JSON) + .when() + .get("/increments/second-key") + .then() + .statusCode(200) + .body("key", is("second-key")) + .body("value", is(1010)); + + // verify that we have two keys in registered + given() + .accept(ContentType.JSON) + .when() + .get("/increments") + .then() + .statusCode(200) + .body("size()", is(2)); + + // delete first key + given() + .accept(ContentType.JSON) + .when() + .delete("/increments/first-key") + .then() + .statusCode(204); + + // verify that we have one key left after deletion + given() + .accept(ContentType.JSON) + .when() + .get("/increments") + .then() + .statusCode(200) + .body("size()", is(1)); + + // delete second key + given() + .accept(ContentType.JSON) + .when() + .delete("/increments/second-key") + .then() + .statusCode(204); + + // verify that there is no key left + given() + .accept(ContentType.JSON) + .when() + .get("/increments") + .then() + .statusCode(200) + .body("size()", is(0)); + } +} +---- + +== Get it running + +If you followed the instructions, you should have the Redis server running. +Then, you just need to run the application using: + +[source, shell] +---- +./mvnw quarkus:dev +---- + +Open another terminal and run the `curl http://localhost:8080/increments` command. + +== Interacting with the application +As we have seen above, the API exposes five Rest endpoints. +In this section we are going to see how to initialise an increment, see the list of current increments, +incrementing a value given its key, retrieving the current value of an increment, and finally deleting +a key. + +=== Creating a new increment + +[source, shell] +---- +curl -X POST -H "Content-Type: application/json" -d '{"key":"first","value":10}' http://localhost:8080/increments <1> +---- + +1. We create the first increment, with the key `first` and an initial value of `10`. + +Running the above command should return the result below: + +[source, json] +----- +{ + "key": "first", + "value": 10 +} +----- + +=== See current increments keys + +To see the list of current increments keys, run the following command: + +[source, shell] +---- +curl http://localhost:8080/increments +---- + +The above command should return `["first"]` indicating that we have only one increment thus far. + +=== Retrieve a new increment + +To retrieve an increment using its key, we will have to run the below command: + +[source, shell] +---- +curl http://localhost:8080/increments/first <1> +---- + +1. Running this command, should return the following result: + +[source, json] +---- +{ + "key": "first", + "value": 10 +} +---- + +=== Increment a value given its key + +To increment a value, run the following command: + +[source, shell] +---- +curl -X PUT -H "Content-Type: application/json" -d '27' http://localhost:8080/increments/first <1> +---- + +1. Increment the `first` value by 27. + +Now, running the command `curl http://localhost:8080/increments/first` should return the following result: + +[source, json] +---- +{ + "key": "first", + "value": 37 <1> +} +---- + +1. We see that the value of the `first` key is now `37` which is exactly the result of `10 + 27`, quick maths. + +=== Deleting a key + +Use the command below, to delete an increment given its key. + +[source, shell] +---- +curl -X DELETE http://localhost:8080/increments/first <1> +---- + +1. Delete the `first` increment. + +Now, running the command `curl http://localhost:8080/increments` should return an empty list `[]` + +== Packaging and running in JVM mode + +You can run the application as a conventional jar file. + +First, we will need to package it: + +[source, shell] +---- +./mvnw package +---- + +NOTE: This command will start a Redis instance to execute the tests. Thus your Redis containers need to be stopped. + +Then run it: + +[source, shell] +---- +java -jar ./target/redis-quickstart-1.0-SNAPSHOT-runner.jar +---- + +== Running Native + +You can also create a native executable from this application without making any +source code changes. A native executable removes the dependency on the JVM: +everything needed to run the application on the target platform is included in +the executable, allowing the application to run with minimal resource overhead. + +Compiling a native executable takes a bit longer, as GraalVM performs additional +steps to remove unnecessary codepaths. Use the `native` profile to compile a +native executable: + +[source, shell] +---- +./mvnw package -Pnative +---- + +Once the build is finished, you can run the executable with: + +[source, shell] +---- +./target/redis-quickstart-1.0-SNAPSHOT-runner +---- + +== Connection Health Check + +If you are using the `quarkus-smallrye-health` extension, `quarkus-vertx-redis` will automatically add a readiness health check +to validate the connection to the Redis server. + +So when you access the `/health/ready` endpoint of your application you will have information about the connection validation status. + +This behavior can be disabled by setting the `quarkus.redis.health.enabled` property to `false` in your `application.properties`. + +== Configuration Reference + +include::{generated-dir}/config/quarkus-redis-client.adoc[opts=optional, leveloffset=+1] diff --git a/extensions/pom.xml b/extensions/pom.xml index 54c9f30235709..06ba7ae54d132 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -76,6 +76,7 @@ reactive-mysql-client mailer grpc + redis-client narayana-jta diff --git a/extensions/redis-client/deployment/pom.xml b/extensions/redis-client/deployment/pom.xml new file mode 100644 index 0000000000000..428efb057fc7f --- /dev/null +++ b/extensions/redis-client/deployment/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + + io.quarkus + quarkus-redis-client-parent + 999-SNAPSHOT + ../ + + + quarkus-redis-client-deployment + + Quarkus - Redis Client - Deployment + + + + io.quarkus + quarkus-vertx-deployment + + + io.quarkus + quarkus-redis-client + + + io.quarkus + quarkus-smallrye-health-spi + + + io.quarkus + quarkus-junit5-internal + test + + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + + + diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/RedisBuildTimeConfig.java b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/RedisBuildTimeConfig.java new file mode 100644 index 0000000000000..4e9ab8a47bed4 --- /dev/null +++ b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/RedisBuildTimeConfig.java @@ -0,0 +1,13 @@ +package io.quarkus.redis.client.deployment; + +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigRoot; + +@ConfigRoot +public class RedisBuildTimeConfig { + /** + * Whether or not an health check is published in case the smallrye-health extension is present. + */ + @ConfigItem(name = "health.enabled", defaultValue = "true") + public boolean healthEnabled; +} diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/RedisClientProcessor.java b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/RedisClientProcessor.java new file mode 100644 index 0000000000000..0c0a29c8c3518 --- /dev/null +++ b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/RedisClientProcessor.java @@ -0,0 +1,38 @@ +package io.quarkus.redis.client.deployment; + +import io.quarkus.arc.deployment.AdditionalBeanBuildItem; +import io.quarkus.deployment.Feature; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; +import io.quarkus.smallrye.health.deployment.spi.HealthBuildItem; +import io.vertx.redis.client.impl.types.BulkType; + +public class RedisClientProcessor { + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(Feature.REDIS_CLIENT); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(Feature.REDIS_CLIENT.getName()); + } + + @BuildStep + AdditionalBeanBuildItem registerAPIsProducer() { + return AdditionalBeanBuildItem.unremovableOf("io.quarkus.redis.client.runtime.RedisAPIProducer"); + } + + @BuildStep + HealthBuildItem addHealthCheck(RedisBuildTimeConfig buildTimeConfig) { + return new HealthBuildItem("io.quarkus.redis.client.runtime.health.RedisHealthCheck", buildTimeConfig.healthEnabled); + } + + @BuildStep + RuntimeInitializedClassBuildItem initializeBulkTypeDuringRuntime() { + return new RuntimeInitializedClassBuildItem(BulkType.class.getName()); + } +} diff --git a/extensions/redis-client/pom.xml b/extensions/redis-client/pom.xml new file mode 100644 index 0000000000000..953b70056bec7 --- /dev/null +++ b/extensions/redis-client/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + + quarkus-build-parent + io.quarkus + 999-SNAPSHOT + ../../build-parent/pom.xml + + + quarkus-redis-client-parent + pom + + Quarkus - Redis Client + + + deployment + runtime + + + + diff --git a/extensions/redis-client/runtime/pom.xml b/extensions/redis-client/runtime/pom.xml new file mode 100644 index 0000000000000..2d37cc78cbc19 --- /dev/null +++ b/extensions/redis-client/runtime/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + io.quarkus + quarkus-redis-client-parent + 999-SNAPSHOT + ../ + + + quarkus-redis-client + + Quarkus - Redis Client - Runtime + Connect to Redis in either imperative or reactive style + + + io.quarkus + quarkus-vertx + + + io.smallrye.reactive + smallrye-mutiny-vertx-redis-client + + + + io.quarkus + quarkus-smallrye-health + true + + + io.quarkus + quarkus-junit5-internal + test + + + org.assertj + assertj-core + test + + + + + + + io.quarkus + quarkus-bootstrap-maven-plugin + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + + diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/RedisClient.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/RedisClient.java new file mode 100644 index 0000000000000..68cbe8bcd3dfc --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/RedisClient.java @@ -0,0 +1,417 @@ +package io.quarkus.redis.client; + +import java.util.List; + +import io.vertx.redis.client.Response; + +/** + * A synchronous Redis client offering blocking Redis commands. + * The commands have a default timeout of 10 seconds which can be configured + * via {@code quarkus.redis.timeout} configuration knob. + * + * For more information about how each individual command visit + * the Redis Commands Page + */ +public interface RedisClient { + void close(); + + Response append(String arg0, String arg1); + + Response asking(); + + Response auth(String arg0); + + Response bgrewriteaof(); + + Response bgsave(List args); + + Response bitcount(List args); + + Response bitfield(List args); + + Response bitop(List args); + + Response bitpos(List args); + + Response blpop(List args); + + Response brpop(List args); + + Response brpoplpush(String arg0, String arg1, String arg2); + + Response bzpopmax(List args); + + Response bzpopmin(List args); + + Response client(List args); + + Response cluster(List args); + + Response command(); + + Response config(List args); + + Response dbsize(); + + Response debug(List args); + + Response decr(String arg0); + + Response decrby(String arg0, String arg1); + + Response del(List args); + + Response discard(); + + Response dump(String arg0); + + Response echo(String arg0); + + Response eval(List args); + + Response evalsha(List args); + + Response exec(); + + Response exists(List args); + + Response expire(String arg0, String arg1); + + Response expireat(String arg0, String arg1); + + Response flushall(List args); + + Response flushdb(List args); + + Response geoadd(List args); + + Response geodist(List args); + + Response geohash(List args); + + Response geopos(List args); + + Response georadius(List args); + + Response georadiusRo(List args); + + Response georadiusbymember(List args); + + Response georadiusbymemberRo(List args); + + Response get(String arg0); + + Response getbit(String arg0, String arg1); + + Response getrange(String arg0, String arg1, String arg2); + + Response getset(String arg0, String arg1); + + Response hdel(List args); + + Response hexists(String arg0, String arg1); + + Response hget(String arg0, String arg1); + + Response hgetall(String arg0); + + Response hincrby(String arg0, String arg1, String arg2); + + Response hincrbyfloat(String arg0, String arg1, String arg2); + + Response hkeys(String arg0); + + Response hlen(String arg0); + + Response hmget(List args); + + Response hmset(List args); + + Response host(List args); + + Response hscan(List args); + + Response hset(List args); + + Response hsetnx(String arg0, String arg1, String arg2); + + Response hstrlen(String arg0, String arg1); + + Response hvals(String arg0); + + Response incr(String arg0); + + Response incrby(String arg0, String arg1); + + Response incrbyfloat(String arg0, String arg1); + + Response info(List args); + + Response keys(String arg0); + + Response lastsave(); + + Response latency(List args); + + Response lindex(String arg0, String arg1); + + Response linsert(String arg0, String arg1, String arg2, String arg3); + + Response llen(String arg0); + + Response lolwut(List args); + + Response lpop(String arg0); + + Response lpush(List args); + + Response lpushx(List args); + + Response lrange(String arg0, String arg1, String arg2); + + Response lrem(String arg0, String arg1, String arg2); + + Response lset(String arg0, String arg1, String arg2); + + Response ltrim(String arg0, String arg1, String arg2); + + Response memory(List args); + + Response mget(List args); + + Response migrate(List args); + + Response module(List args); + + Response monitor(); + + Response move(String arg0, String arg1); + + Response mset(List args); + + Response msetnx(List args); + + Response multi(); + + Response object(List args); + + Response persist(String arg0); + + Response pexpire(String arg0, String arg1); + + Response pexpireat(String arg0, String arg1); + + Response pfadd(List args); + + Response pfcount(List args); + + Response pfdebug(List args); + + Response pfmerge(List args); + + Response pfselftest(); + + Response ping(List args); + + Response post(List args); + + Response psetex(String arg0, String arg1, String arg2); + + Response psubscribe(List args); + + Response psync(String arg0, String arg1); + + Response pttl(String arg0); + + Response publish(String arg0, String arg1); + + Response pubsub(List args); + + Response punsubscribe(List args); + + Response randomkey(); + + Response readonly(); + + Response readwrite(); + + Response rename(String arg0, String arg1); + + Response renamenx(String arg0, String arg1); + + Response replconf(List args); + + Response replicaof(String arg0, String arg1); + + Response restore(List args); + + Response restoreAsking(List args); + + Response role(); + + Response rpop(String arg0); + + Response rpoplpush(String arg0, String arg1); + + Response rpush(List args); + + Response rpushx(List args); + + Response sadd(List args); + + Response save(); + + Response scan(List args); + + Response scard(String arg0); + + Response script(List args); + + Response sdiff(List args); + + Response sdiffstore(List args); + + Response select(String arg0); + + Response set(List args); + + Response setbit(String arg0, String arg1, String arg2); + + Response setex(String arg0, String arg1, String arg2); + + Response setnx(String arg0, String arg1); + + Response setrange(String arg0, String arg1, String arg2); + + Response shutdown(List args); + + Response sinter(List args); + + Response sinterstore(List args); + + Response sismember(String arg0, String arg1); + + Response slaveof(String arg0, String arg1); + + Response slowlog(List args); + + Response smembers(String arg0); + + Response smove(String arg0, String arg1, String arg2); + + Response sort(List args); + + Response spop(List args); + + Response srandmember(List args); + + Response srem(List args); + + Response sscan(List args); + + Response strlen(String arg0); + + Response subscribe(List args); + + Response substr(String arg0, String arg1, String arg2); + + Response sunion(List args); + + Response sunionstore(List args); + + Response swapdb(String arg0, String arg1); + + Response sync(); + + Response time(); + + Response touch(List args); + + Response ttl(String arg0); + + Response type(String arg0); + + Response unlink(List args); + + Response unsubscribe(List args); + + Response unwatch(); + + Response wait(String arg0, String arg1); + + Response watch(List args); + + Response xack(List args); + + Response xadd(List args); + + Response xclaim(List args); + + Response xdel(List args); + + Response xgroup(List args); + + Response xinfo(List args); + + Response xlen(String arg0); + + Response xpending(List args); + + Response xrange(List args); + + Response xread(List args); + + Response xreadgroup(List args); + + Response xrevrange(List args); + + Response xsetid(String arg0, String arg1); + + Response xtrim(List args); + + Response zadd(List args); + + Response zcard(String arg0); + + Response zcount(String arg0, String arg1, String arg2); + + Response zincrby(String arg0, String arg1, String arg2); + + Response zinterstore(List args); + + Response zlexcount(String arg0, String arg1, String arg2); + + Response zpopmax(List args); + + Response zpopmin(List args); + + Response zrange(List args); + + Response zrangebylex(List args); + + Response zrangebyscore(List args); + + Response zrank(String arg0, String arg1); + + Response zrem(List args); + + Response zremrangebylex(String arg0, String arg1, String arg2); + + Response zremrangebyrank(String arg0, String arg1, String arg2); + + Response zremrangebyscore(String arg0, String arg1, String arg2); + + Response zrevrange(List args); + + Response zrevrangebylex(List args); + + Response zrevrangebyscore(List args); + + Response zrevrank(String arg0, String arg1); + + Response zscan(List args); + + Response zscore(String arg0, String arg1); + + Response zunionstore(List args); +} diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/reactive/ReactiveRedisClient.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/reactive/ReactiveRedisClient.java new file mode 100644 index 0000000000000..cc03fef38ac82 --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/reactive/ReactiveRedisClient.java @@ -0,0 +1,816 @@ +package io.quarkus.redis.client.reactive; + +import java.util.List; + +import io.smallrye.mutiny.Uni; +import io.vertx.mutiny.redis.client.Response; + +/** + * A Redis client offering reactive Redis commands. + * + * For more information about how each individual command visit + * the Redis Commands Page + */ +public interface ReactiveRedisClient { + void close(); + + Uni append(String arg0, String arg1); + + Response appendAndAwait(String arg0, String arg1); + + Uni asking(); + + Response askingAndAwait(); + + Uni auth(String arg0); + + Response authAndAwait(String arg0); + + Uni bgrewriteaof(); + + Response bgrewriteaofAndAwait(); + + Uni bgsave(List args); + + Response bgsaveAndAwait(List args); + + Uni bitcount(List args); + + Response bitcountAndAwait(List args); + + Uni bitfield(List args); + + Response bitfieldAndAwait(List args); + + Uni bitop(List args); + + Response bitopAndAwait(List args); + + Uni bitpos(List args); + + Response bitposAndAwait(List args); + + Uni blpop(List args); + + Response blpopAndAwait(List args); + + Uni brpop(List args); + + Response brpopAndAwait(List args); + + Uni brpoplpush(String arg0, String arg1, String arg2); + + Response brpoplpushAndAwait(String arg0, String arg1, String arg2); + + Uni bzpopmax(List args); + + Response bzpopmaxAndAwait(List args); + + Uni bzpopmin(List args); + + Response bzpopminAndAwait(List args); + + Uni client(List args); + + Response clientAndAwait(List args); + + Uni cluster(List args); + + Response clusterAndAwait(List args); + + Uni command(); + + Response commandAndAwait(); + + Uni config(List args); + + Response configAndAwait(List args); + + Uni dbsize(); + + Response dbsizeAndAwait(); + + Uni debug(List args); + + Response debugAndAwait(List args); + + Uni decr(String arg0); + + Response decrAndAwait(String arg0); + + Uni decrby(String arg0, String arg1); + + Response decrbyAndAwait(String arg0, String arg1); + + Uni del(List args); + + Response delAndAwait(List args); + + Uni discard(); + + Response discardAndAwait(); + + Uni dump(String arg0); + + Response dumpAndAwait(String arg0); + + Uni echo(String arg0); + + Response echoAndAwait(String arg0); + + Uni eval(List args); + + Response evalAndAwait(List args); + + Uni evalsha(List args); + + Response evalshaAndAwait(List args); + + Uni exec(); + + Response execAndAwait(); + + Uni exists(List args); + + Response existsAndAwait(List args); + + Uni expire(String arg0, String arg1); + + Response expireAndAwait(String arg0, String arg1); + + Uni expireat(String arg0, String arg1); + + Response expireatAndAwait(String arg0, String arg1); + + Uni flushall(List args); + + Response flushallAndAwait(List args); + + Uni flushdb(List args); + + Response flushdbAndAwait(List args); + + Uni geoadd(List args); + + Response geoaddAndAwait(List args); + + Uni geodist(List args); + + Response geodistAndAwait(List args); + + Uni geohash(List args); + + Response geohashAndAwait(List args); + + Uni geopos(List args); + + Response geoposAndAwait(List args); + + Uni georadius(List args); + + Response georadiusAndAwait(List args); + + Uni georadiusRo(List args); + + Response georadiusRoAndAwait(List args); + + Uni georadiusbymember(List args); + + Response georadiusbymemberAndAwait(List args); + + Uni georadiusbymemberRo(List args); + + Response georadiusbymemberRoAndAwait(List args); + + Uni get(String arg0); + + Response getAndAwait(String arg0); + + Uni getbit(String arg0, String arg1); + + Response getbitAndAwait(String arg0, String arg1); + + Uni getrange(String arg0, String arg1, String arg2); + + Response getrangeAndAwait(String arg0, String arg1, String arg2); + + Uni getset(String arg0, String arg1); + + Response getsetAndAwait(String arg0, String arg1); + + Uni hdel(List args); + + Response hdelAndAwait(List args); + + Uni hexists(String arg0, String arg1); + + Response hexistsAndAwait(String arg0, String arg1); + + Uni hget(String arg0, String arg1); + + Response hgetAndAwait(String arg0, String arg1); + + Uni hgetall(String arg0); + + Response hgetallAndAwait(String arg0); + + Uni hincrby(String arg0, String arg1, String arg2); + + Response hincrbyAndAwait(String arg0, String arg1, String arg2); + + Uni hincrbyfloat(String arg0, String arg1, String arg2); + + Response hincrbyfloatAndAwait(String arg0, String arg1, String arg2); + + Uni hkeys(String arg0); + + Response hkeysAndAwait(String arg0); + + Uni hlen(String arg0); + + Response hlenAndAwait(String arg0); + + Uni hmget(List args); + + Response hmgetAndAwait(List args); + + Uni hmset(List args); + + Response hmsetAndAwait(List args); + + Uni host(List args); + + Response hostAndAwait(List args); + + Uni hscan(List args); + + Response hscanAndAwait(List args); + + Uni hset(List args); + + Response hsetAndAwait(List args); + + Uni hsetnx(String arg0, String arg1, String arg2); + + Response hsetnxAndAwait(String arg0, String arg1, String arg2); + + Uni hstrlen(String arg0, String arg1); + + Response hstrlenAndAwait(String arg0, String arg1); + + Uni hvals(String arg0); + + Response hvalsAndAwait(String arg0); + + Uni incr(String arg0); + + Response incrAndAwait(String arg0); + + Uni incrby(String arg0, String arg1); + + Response incrbyAndAwait(String arg0, String arg1); + + Uni incrbyfloat(String arg0, String arg1); + + Response incrbyfloatAndAwait(String arg0, String arg1); + + Uni info(List args); + + Response infoAndAwait(List args); + + Uni keys(String arg0); + + Response keysAndAwait(String arg0); + + Uni lastsave(); + + Response lastsaveAndAwait(); + + Uni latency(List args); + + Response latencyAndAwait(List args); + + Uni lindex(String arg0, String arg1); + + Response lindexAndAwait(String arg0, String arg1); + + Uni linsert(String arg0, String arg1, String arg2, String arg3); + + Response linsertAndAwait(String arg0, String arg1, String arg2, String arg3); + + Uni llen(String arg0); + + Response llenAndAwait(String arg0); + + Uni lolwut(List args); + + Response lolwutAndAwait(List args); + + Uni lpop(String arg0); + + Response lpopAndAwait(String arg0); + + Uni lpush(List args); + + Response lpushAndAwait(List args); + + Uni lpushx(List args); + + Response lpushxAndAwait(List args); + + Uni lrange(String arg0, String arg1, String arg2); + + Response lrangeAndAwait(String arg0, String arg1, String arg2); + + Uni lrem(String arg0, String arg1, String arg2); + + Response lremAndAwait(String arg0, String arg1, String arg2); + + Uni lset(String arg0, String arg1, String arg2); + + Response lsetAndAwait(String arg0, String arg1, String arg2); + + Uni ltrim(String arg0, String arg1, String arg2); + + Response ltrimAndAwait(String arg0, String arg1, String arg2); + + Uni memory(List args); + + Response memoryAndAwait(List args); + + Uni mget(List args); + + Response mgetAndAwait(List args); + + Uni migrate(List args); + + Response migrateAndAwait(List args); + + Uni module(List args); + + Response moduleAndAwait(List args); + + Uni monitor(); + + Response monitorAndAwait(); + + Uni move(String arg0, String arg1); + + Response moveAndAwait(String arg0, String arg1); + + Uni mset(List args); + + Response msetAndAwait(List args); + + Uni msetnx(List args); + + Response msetnxAndAwait(List args); + + Uni multi(); + + Response multiAndAwait(); + + Uni object(List args); + + Response objectAndAwait(List args); + + Uni persist(String arg0); + + Response persistAndAwait(String arg0); + + Uni pexpire(String arg0, String arg1); + + Response pexpireAndAwait(String arg0, String arg1); + + Uni pexpireat(String arg0, String arg1); + + Response pexpireatAndAwait(String arg0, String arg1); + + Uni pfadd(List args); + + Response pfaddAndAwait(List args); + + Uni pfcount(List args); + + Response pfcountAndAwait(List args); + + Uni pfdebug(List args); + + Response pfdebugAndAwait(List args); + + Uni pfmerge(List args); + + Response pfmergeAndAwait(List args); + + Uni pfselftest(); + + Response pfselftestAndAwait(); + + Uni ping(List args); + + Response pingAndAwait(List args); + + Uni post(List args); + + Response postAndAwait(List args); + + Uni psetex(String arg0, String arg1, String arg2); + + Response psetexAndAwait(String arg0, String arg1, String arg2); + + Uni psubscribe(List args); + + Response psubscribeAndAwait(List args); + + Uni psync(String arg0, String arg1); + + Response psyncAndAwait(String arg0, String arg1); + + Uni pttl(String arg0); + + Response pttlAndAwait(String arg0); + + Uni publish(String arg0, String arg1); + + Response publishAndAwait(String arg0, String arg1); + + Uni pubsub(List args); + + Response pubsubAndAwait(List args); + + Uni punsubscribe(List args); + + Response punsubscribeAndAwait(List args); + + Uni randomkey(); + + Response randomkeyAndAwait(); + + Uni readonly(); + + Response readonlyAndAwait(); + + Uni readwrite(); + + Response readwriteAndAwait(); + + Uni rename(String arg0, String arg1); + + Response renameAndAwait(String arg0, String arg1); + + Uni renamenx(String arg0, String arg1); + + Response renamenxAndAwait(String arg0, String arg1); + + Uni replconf(List args); + + Response replconfAndAwait(List args); + + Uni replicaof(String arg0, String arg1); + + Response replicaofAndAwait(String arg0, String arg1); + + Uni restore(List args); + + Response restoreAndAwait(List args); + + Uni restoreAsking(List args); + + Response restoreAskingAndAwait(List args); + + Uni role(); + + Response roleAndAwait(); + + Uni rpop(String arg0); + + Response rpopAndAwait(String arg0); + + Uni rpoplpush(String arg0, String arg1); + + Response rpoplpushAndAwait(String arg0, String arg1); + + Uni rpush(List args); + + Response rpushAndAwait(List args); + + Uni rpushx(List args); + + Response rpushxAndAwait(List args); + + Uni sadd(List args); + + Response saddAndAwait(List args); + + Uni save(); + + Response saveAndAwait(); + + Uni scan(List args); + + Response scanAndAwait(List args); + + Uni scard(String arg0); + + Response scardAndAwait(String arg0); + + Uni script(List args); + + Response scriptAndAwait(List args); + + Uni sdiff(List args); + + Response sdiffAndAwait(List args); + + Uni sdiffstore(List args); + + Response sdiffstoreAndAwait(List args); + + Uni select(String arg0); + + Response selectAndAwait(String arg0); + + Uni set(List args); + + Response setAndAwait(List args); + + Uni setbit(String arg0, String arg1, String arg2); + + Response setbitAndAwait(String arg0, String arg1, String arg2); + + Uni setex(String arg0, String arg1, String arg2); + + Response setexAndAwait(String arg0, String arg1, String arg2); + + Uni setnx(String arg0, String arg1); + + Response setnxAndAwait(String arg0, String arg1); + + Uni setrange(String arg0, String arg1, String arg2); + + Response setrangeAndAwait(String arg0, String arg1, String arg2); + + Uni shutdown(List args); + + Response shutdownAndAwait(List args); + + Uni sinter(List args); + + Response sinterAndAwait(List args); + + Uni sinterstore(List args); + + Response sinterstoreAndAwait(List args); + + Uni sismember(String arg0, String arg1); + + Response sismemberAndAwait(String arg0, String arg1); + + Uni slaveof(String arg0, String arg1); + + Response slaveofAndAwait(String arg0, String arg1); + + Uni slowlog(List args); + + Response slowlogAndAwait(List args); + + Uni smembers(String arg0); + + Response smembersAndAwait(String arg0); + + Uni smove(String arg0, String arg1, String arg2); + + Response smoveAndAwait(String arg0, String arg1, String arg2); + + Uni sort(List args); + + Response sortAndAwait(List args); + + Uni spop(List args); + + Response spopAndAwait(List args); + + Uni srandmember(List args); + + Response srandmemberAndAwait(List args); + + Uni srem(List args); + + Response sremAndAwait(List args); + + Uni sscan(List args); + + Response sscanAndAwait(List args); + + Uni strlen(String arg0); + + Response strlenAndAwait(String arg0); + + Uni subscribe(List args); + + Response subscribeAndAwait(List args); + + Uni substr(String arg0, String arg1, String arg2); + + Response substrAndAwait(String arg0, String arg1, String arg2); + + Uni sunion(List args); + + Response sunionAndAwait(List args); + + Uni sunionstore(List args); + + Response sunionstoreAndAwait(List args); + + Uni swapdb(String arg0, String arg1); + + Response swapdbAndAwait(String arg0, String arg1); + + Uni sync(); + + Response syncAndAwait(); + + Uni time(); + + Response timeAndAwait(); + + Uni touch(List args); + + Response touchAndAwait(List args); + + Uni ttl(String arg0); + + Response ttlAndAwait(String arg0); + + Uni type(String arg0); + + Response typeAndAwait(String arg0); + + Uni unlink(List args); + + Response unlinkAndAwait(List args); + + Uni unsubscribe(List args); + + Response unsubscribeAndAwait(List args); + + Uni unwatch(); + + Response unwatchAndAwait(); + + Uni wait(String arg0, String arg1); + + Response waitAndAwait(String arg0, String arg1); + + Uni watch(List args); + + Response watchAndAwait(List args); + + Uni xack(List args); + + Response xackAndAwait(List args); + + Uni xadd(List args); + + Response xaddAndAwait(List args); + + Uni xclaim(List args); + + Response xclaimAndAwait(List args); + + Uni xdel(List args); + + Response xdelAndAwait(List args); + + Uni xgroup(List args); + + Response xgroupAndAwait(List args); + + Uni xinfo(List args); + + Response xinfoAndAwait(List args); + + Uni xlen(String arg0); + + Response xlenAndAwait(String arg0); + + Uni xpending(List args); + + Response xpendingAndAwait(List args); + + Uni xrange(List args); + + Response xrangeAndAwait(List args); + + Uni xread(List args); + + Response xreadAndAwait(List args); + + Uni xreadgroup(List args); + + Response xreadgroupAndAwait(List args); + + Uni xrevrange(List args); + + Response xrevrangeAndAwait(List args); + + Uni xsetid(String arg0, String arg1); + + Response xsetidAndAwait(String arg0, String arg1); + + Uni xtrim(List args); + + Response xtrimAndAwait(List args); + + Uni zadd(List args); + + Response zaddAndAwait(List args); + + Uni zcard(String arg0); + + Response zcardAndAwait(String arg0); + + Uni zcount(String arg0, String arg1, String arg2); + + Response zcountAndAwait(String arg0, String arg1, String arg2); + + Uni zincrby(String arg0, String arg1, String arg2); + + Response zincrbyAndAwait(String arg0, String arg1, String arg2); + + Uni zinterstore(List args); + + Response zinterstoreAndAwait(List args); + + Uni zlexcount(String arg0, String arg1, String arg2); + + Response zlexcountAndAwait(String arg0, String arg1, String arg2); + + Uni zpopmax(List args); + + Response zpopmaxAndAwait(List args); + + Uni zpopmin(List args); + + Response zpopminAndAwait(List args); + + Uni zrange(List args); + + Response zrangeAndAwait(List args); + + Uni zrangebylex(List args); + + Response zrangebylexAndAwait(List args); + + Uni zrangebyscore(List args); + + Response zrangebyscoreAndAwait(List args); + + Uni zrank(String arg0, String arg1); + + Response zrankAndAwait(String arg0, String arg1); + + Uni zrem(List args); + + Response zremAndAwait(List args); + + Uni zremrangebylex(String arg0, String arg1, String arg2); + + Response zremrangebylexAndAwait(String arg0, String arg1, String arg2); + + Uni zremrangebyrank(String arg0, String arg1, String arg2); + + Response zremrangebyrankAndAwait(String arg0, String arg1, String arg2); + + Uni zremrangebyscore(String arg0, String arg1, String arg2); + + Response zremrangebyscoreAndAwait(String arg0, String arg1, String arg2); + + Uni zrevrange(List args); + + Response zrevrangeAndAwait(List args); + + Uni zrevrangebylex(List args); + + Response zrevrangebylexAndAwait(List args); + + Uni zrevrangebyscore(List args); + + Response zrevrangebyscoreAndAwait(List args); + + Uni zrevrank(String arg0, String arg1); + + Response zrevrankAndAwait(String arg0, String arg1); + + Uni zscan(List args); + + Response zscanAndAwait(List args); + + Uni zscore(String arg0, String arg1); + + Response zscoreAndAwait(String arg0, String arg1); + + Uni zunionstore(List args); + + Response zunionstoreAndAwait(List args); +} diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/ReactiveRedisClientImpl.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/ReactiveRedisClientImpl.java new file mode 100644 index 0000000000000..63045ccaae0a1 --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/ReactiveRedisClientImpl.java @@ -0,0 +1,2021 @@ +package io.quarkus.redis.client.runtime; + +import java.util.List; + +import io.quarkus.redis.client.reactive.ReactiveRedisClient; +import io.smallrye.mutiny.Uni; +import io.vertx.mutiny.redis.client.RedisAPI; +import io.vertx.mutiny.redis.client.Response; + +class ReactiveRedisClientImpl implements ReactiveRedisClient { + private final RedisAPI redisAPI; + + public ReactiveRedisClientImpl(RedisAPI redisAPI) { + this.redisAPI = redisAPI; + } + + @Override + public void close() { + redisAPI.close(); + } + + @Override + public Uni append(String arg0, String arg1) { + return redisAPI.append(arg0, arg1); + } + + @Override + public Response appendAndAwait(String arg0, String arg1) { + return redisAPI.appendAndAwait(arg0, arg1); + } + + @Override + public Uni asking() { + return redisAPI.asking(); + } + + @Override + public Response askingAndAwait() { + return redisAPI.askingAndAwait(); + } + + @Override + public Uni auth(String arg0) { + return redisAPI.auth(arg0); + } + + @Override + public Response authAndAwait(String arg0) { + return redisAPI.authAndAwait(arg0); + } + + @Override + public Uni bgrewriteaof() { + return redisAPI.bgrewriteaof(); + } + + @Override + public Response bgrewriteaofAndAwait() { + return redisAPI.bgrewriteaofAndAwait(); + } + + @Override + public Uni bgsave(List args) { + return redisAPI.bgsave(args); + } + + @Override + public Response bgsaveAndAwait(List args) { + return redisAPI.bgsaveAndAwait(args); + } + + @Override + public Uni bitcount(List args) { + return redisAPI.bitcount(args); + } + + @Override + public Response bitcountAndAwait(List args) { + return redisAPI.bitcountAndAwait(args); + } + + @Override + public Uni bitfield(List args) { + return redisAPI.bitfield(args); + } + + @Override + public Response bitfieldAndAwait(List args) { + return redisAPI.bitfieldAndAwait(args); + } + + @Override + public Uni bitop(List args) { + return redisAPI.bitop(args); + } + + @Override + public Response bitopAndAwait(List args) { + return redisAPI.bitopAndAwait(args); + } + + @Override + public Uni bitpos(List args) { + return redisAPI.bitpos(args); + } + + @Override + public Response bitposAndAwait(List args) { + return redisAPI.bitposAndAwait(args); + } + + @Override + public Uni blpop(List args) { + return redisAPI.blpop(args); + } + + @Override + public Response blpopAndAwait(List args) { + return redisAPI.blpopAndAwait(args); + } + + @Override + public Uni brpop(List args) { + return redisAPI.brpop(args); + } + + @Override + public Response brpopAndAwait(List args) { + return redisAPI.brpopAndAwait(args); + } + + @Override + public Uni brpoplpush(String arg0, String arg1, String arg2) { + return redisAPI.brpoplpush(arg0, arg1, arg2); + } + + @Override + public Response brpoplpushAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.brpoplpushAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni bzpopmax(List args) { + return redisAPI.bzpopmax(args); + } + + @Override + public Response bzpopmaxAndAwait(List args) { + return redisAPI.bzpopmaxAndAwait(args); + } + + @Override + public Uni bzpopmin(List args) { + return redisAPI.bzpopmin(args); + } + + @Override + public Response bzpopminAndAwait(List args) { + return redisAPI.bzpopminAndAwait(args); + } + + @Override + public Uni client(List args) { + return redisAPI.client(args); + } + + @Override + public Response clientAndAwait(List args) { + return redisAPI.clientAndAwait(args); + } + + @Override + public Uni cluster(List args) { + return redisAPI.cluster(args); + } + + @Override + public Response clusterAndAwait(List args) { + return redisAPI.clusterAndAwait(args); + } + + @Override + public Uni command() { + return redisAPI.command(); + } + + @Override + public Response commandAndAwait() { + return redisAPI.commandAndAwait(); + } + + @Override + public Uni config(List args) { + return redisAPI.config(args); + } + + @Override + public Response configAndAwait(List args) { + return redisAPI.configAndAwait(args); + } + + @Override + public Uni dbsize() { + return redisAPI.dbsize(); + } + + @Override + public Response dbsizeAndAwait() { + return redisAPI.dbsizeAndAwait(); + } + + @Override + public Uni debug(List args) { + return redisAPI.debug(args); + } + + @Override + public Response debugAndAwait(List args) { + return redisAPI.debugAndAwait(args); + } + + @Override + public Uni decr(String arg0) { + return redisAPI.decr(arg0); + } + + @Override + public Response decrAndAwait(String arg0) { + return redisAPI.decrAndAwait(arg0); + } + + @Override + public Uni decrby(String arg0, String arg1) { + return redisAPI.decrby(arg0, arg1); + } + + @Override + public Response decrbyAndAwait(String arg0, String arg1) { + return redisAPI.decrbyAndAwait(arg0, arg1); + } + + @Override + public Uni del(List args) { + return redisAPI.del(args); + } + + @Override + public Response delAndAwait(List args) { + return redisAPI.delAndAwait(args); + } + + @Override + public Uni discard() { + return redisAPI.discard(); + } + + @Override + public Response discardAndAwait() { + return redisAPI.discardAndAwait(); + } + + @Override + public Uni dump(String arg0) { + return redisAPI.dump(arg0); + } + + @Override + public Response dumpAndAwait(String arg0) { + return redisAPI.dumpAndAwait(arg0); + } + + @Override + public Uni echo(String arg0) { + return redisAPI.echo(arg0); + } + + @Override + public Response echoAndAwait(String arg0) { + return redisAPI.echoAndAwait(arg0); + } + + @Override + public Uni eval(List args) { + return redisAPI.eval(args); + } + + @Override + public Response evalAndAwait(List args) { + return redisAPI.evalAndAwait(args); + } + + @Override + public Uni evalsha(List args) { + return redisAPI.evalsha(args); + } + + @Override + public Response evalshaAndAwait(List args) { + return redisAPI.evalshaAndAwait(args); + } + + @Override + public Uni exec() { + return redisAPI.exec(); + } + + @Override + public Response execAndAwait() { + return redisAPI.execAndAwait(); + } + + @Override + public Uni exists(List args) { + return redisAPI.exists(args); + } + + @Override + public Response existsAndAwait(List args) { + return redisAPI.existsAndAwait(args); + } + + @Override + public Uni expire(String arg0, String arg1) { + return redisAPI.expire(arg0, arg1); + } + + @Override + public Response expireAndAwait(String arg0, String arg1) { + return redisAPI.expireAndAwait(arg0, arg1); + } + + @Override + public Uni expireat(String arg0, String arg1) { + return redisAPI.expireat(arg0, arg1); + } + + @Override + public Response expireatAndAwait(String arg0, String arg1) { + return redisAPI.expireatAndAwait(arg0, arg1); + } + + @Override + public Uni flushall(List args) { + return redisAPI.flushall(args); + } + + @Override + public Response flushallAndAwait(List args) { + return redisAPI.flushallAndAwait(args); + } + + @Override + public Uni flushdb(List args) { + return redisAPI.flushdb(args); + } + + @Override + public Response flushdbAndAwait(List args) { + return redisAPI.flushdbAndAwait(args); + } + + @Override + public Uni geoadd(List args) { + return redisAPI.geoadd(args); + } + + @Override + public Response geoaddAndAwait(List args) { + return redisAPI.geoaddAndAwait(args); + } + + @Override + public Uni geodist(List args) { + return redisAPI.geodist(args); + } + + @Override + public Response geodistAndAwait(List args) { + return redisAPI.geodistAndAwait(args); + } + + @Override + public Uni geohash(List args) { + return redisAPI.geohash(args); + } + + @Override + public Response geohashAndAwait(List args) { + return redisAPI.geohashAndAwait(args); + } + + @Override + public Uni geopos(List args) { + return redisAPI.geopos(args); + } + + @Override + public Response geoposAndAwait(List args) { + return redisAPI.geoposAndAwait(args); + } + + @Override + public Uni georadius(List args) { + return redisAPI.georadius(args); + } + + @Override + public Response georadiusAndAwait(List args) { + return redisAPI.georadiusAndAwait(args); + } + + @Override + public Uni georadiusRo(List args) { + return redisAPI.georadiusRo(args); + } + + @Override + public Response georadiusRoAndAwait(List args) { + return redisAPI.georadiusRoAndAwait(args); + } + + @Override + public Uni georadiusbymember(List args) { + return redisAPI.georadiusbymember(args); + } + + @Override + public Response georadiusbymemberAndAwait(List args) { + return redisAPI.georadiusbymemberAndAwait(args); + } + + @Override + public Uni georadiusbymemberRo(List args) { + return redisAPI.georadiusbymemberRo(args); + } + + @Override + public Response georadiusbymemberRoAndAwait(List args) { + return redisAPI.georadiusbymemberRoAndAwait(args); + } + + @Override + public Uni get(String arg0) { + return redisAPI.get(arg0); + } + + @Override + public Response getAndAwait(String arg0) { + return redisAPI.getAndAwait(arg0); + } + + @Override + public Uni getbit(String arg0, String arg1) { + return redisAPI.getbit(arg0, arg1); + } + + @Override + public Response getbitAndAwait(String arg0, String arg1) { + return redisAPI.getbitAndAwait(arg0, arg1); + } + + @Override + public Uni getrange(String arg0, String arg1, String arg2) { + return redisAPI.getrange(arg0, arg1, arg2); + } + + @Override + public Response getrangeAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.getrangeAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni getset(String arg0, String arg1) { + return redisAPI.getset(arg0, arg1); + } + + @Override + public Response getsetAndAwait(String arg0, String arg1) { + return redisAPI.getsetAndAwait(arg0, arg1); + } + + @Override + public Uni hdel(List args) { + return redisAPI.hdel(args); + } + + @Override + public Response hdelAndAwait(List args) { + return redisAPI.hdelAndAwait(args); + } + + @Override + public Uni hexists(String arg0, String arg1) { + return redisAPI.hexists(arg0, arg1); + } + + @Override + public Response hexistsAndAwait(String arg0, String arg1) { + return redisAPI.hexistsAndAwait(arg0, arg1); + } + + @Override + public Uni hget(String arg0, String arg1) { + return redisAPI.hget(arg0, arg1); + } + + @Override + public Response hgetAndAwait(String arg0, String arg1) { + return redisAPI.hgetAndAwait(arg0, arg1); + } + + @Override + public Uni hgetall(String arg0) { + return redisAPI.hgetall(arg0); + } + + @Override + public Response hgetallAndAwait(String arg0) { + return redisAPI.hgetallAndAwait(arg0); + } + + @Override + public Uni hincrby(String arg0, String arg1, String arg2) { + return redisAPI.hincrby(arg0, arg1, arg2); + } + + @Override + public Response hincrbyAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.hincrbyAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni hincrbyfloat(String arg0, String arg1, String arg2) { + return redisAPI.hincrbyfloat(arg0, arg1, arg2); + } + + @Override + public Response hincrbyfloatAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.hincrbyfloatAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni hkeys(String arg0) { + return redisAPI.hkeys(arg0); + } + + @Override + public Response hkeysAndAwait(String arg0) { + return redisAPI.hkeysAndAwait(arg0); + } + + @Override + public Uni hlen(String arg0) { + return redisAPI.hlen(arg0); + } + + @Override + public Response hlenAndAwait(String arg0) { + return redisAPI.hlenAndAwait(arg0); + } + + @Override + public Uni hmget(List args) { + return redisAPI.hmget(args); + } + + @Override + public Response hmgetAndAwait(List args) { + return redisAPI.hmgetAndAwait(args); + } + + @Override + public Uni hmset(List args) { + return redisAPI.hmset(args); + } + + @Override + public Response hmsetAndAwait(List args) { + return redisAPI.hmsetAndAwait(args); + } + + @Override + public Uni host(List args) { + return redisAPI.host(args); + } + + @Override + public Response hostAndAwait(List args) { + return redisAPI.hostAndAwait(args); + } + + @Override + public Uni hscan(List args) { + return redisAPI.hscan(args); + } + + @Override + public Response hscanAndAwait(List args) { + return redisAPI.hscanAndAwait(args); + } + + @Override + public Uni hset(List args) { + return redisAPI.hset(args); + } + + @Override + public Response hsetAndAwait(List args) { + return redisAPI.hsetAndAwait(args); + } + + @Override + public Uni hsetnx(String arg0, String arg1, String arg2) { + return redisAPI.hsetnx(arg0, arg1, arg2); + } + + @Override + public Response hsetnxAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.hsetnxAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni hstrlen(String arg0, String arg1) { + return redisAPI.hstrlen(arg0, arg1); + } + + @Override + public Response hstrlenAndAwait(String arg0, String arg1) { + return redisAPI.hstrlenAndAwait(arg0, arg1); + } + + @Override + public Uni hvals(String arg0) { + return redisAPI.hvals(arg0); + } + + @Override + public Response hvalsAndAwait(String arg0) { + return redisAPI.hvalsAndAwait(arg0); + } + + @Override + public Uni incr(String arg0) { + return redisAPI.incr(arg0); + } + + @Override + public Response incrAndAwait(String arg0) { + return redisAPI.incrAndAwait(arg0); + } + + @Override + public Uni incrby(String arg0, String arg1) { + return redisAPI.incrby(arg0, arg1); + } + + @Override + public Response incrbyAndAwait(String arg0, String arg1) { + return redisAPI.incrbyAndAwait(arg0, arg1); + } + + @Override + public Uni incrbyfloat(String arg0, String arg1) { + return redisAPI.incrbyfloat(arg0, arg1); + } + + @Override + public Response incrbyfloatAndAwait(String arg0, String arg1) { + return redisAPI.incrbyfloatAndAwait(arg0, arg1); + } + + @Override + public Uni info(List args) { + return redisAPI.info(args); + } + + @Override + public Response infoAndAwait(List args) { + return redisAPI.infoAndAwait(args); + } + + @Override + public Uni keys(String arg0) { + return redisAPI.keys(arg0); + } + + @Override + public Response keysAndAwait(String arg0) { + return redisAPI.keysAndAwait(arg0); + } + + @Override + public Uni lastsave() { + return redisAPI.lastsave(); + } + + @Override + public Response lastsaveAndAwait() { + return redisAPI.lastsaveAndAwait(); + } + + @Override + public Uni latency(List args) { + return redisAPI.latency(args); + } + + @Override + public Response latencyAndAwait(List args) { + return redisAPI.latencyAndAwait(args); + } + + @Override + public Uni lindex(String arg0, String arg1) { + return redisAPI.lindex(arg0, arg1); + } + + @Override + public Response lindexAndAwait(String arg0, String arg1) { + return redisAPI.lindexAndAwait(arg0, arg1); + } + + @Override + public Uni linsert(String arg0, String arg1, String arg2, String arg3) { + return redisAPI.linsert(arg0, arg1, arg2, arg3); + } + + @Override + public Response linsertAndAwait(String arg0, String arg1, String arg2, String arg3) { + return redisAPI.linsertAndAwait(arg0, arg1, arg2, arg3); + } + + @Override + public Uni llen(String arg0) { + return redisAPI.llen(arg0); + } + + @Override + public Response llenAndAwait(String arg0) { + return redisAPI.llenAndAwait(arg0); + } + + @Override + public Uni lolwut(List args) { + return redisAPI.lolwut(args); + } + + @Override + public Response lolwutAndAwait(List args) { + return redisAPI.lolwutAndAwait(args); + } + + @Override + public Uni lpop(String arg0) { + return redisAPI.lpop(arg0); + } + + @Override + public Response lpopAndAwait(String arg0) { + return redisAPI.lpopAndAwait(arg0); + } + + @Override + public Uni lpush(List args) { + return redisAPI.lpush(args); + } + + @Override + public Response lpushAndAwait(List args) { + return redisAPI.lpushAndAwait(args); + } + + @Override + public Uni lpushx(List args) { + return redisAPI.lpushx(args); + } + + @Override + public Response lpushxAndAwait(List args) { + return redisAPI.lpushxAndAwait(args); + } + + @Override + public Uni lrange(String arg0, String arg1, String arg2) { + return redisAPI.lrange(arg0, arg1, arg2); + } + + @Override + public Response lrangeAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.lrangeAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni lrem(String arg0, String arg1, String arg2) { + return redisAPI.lrem(arg0, arg1, arg2); + } + + @Override + public Response lremAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.lremAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni lset(String arg0, String arg1, String arg2) { + return redisAPI.lset(arg0, arg1, arg2); + } + + @Override + public Response lsetAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.lsetAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni ltrim(String arg0, String arg1, String arg2) { + return redisAPI.ltrim(arg0, arg1, arg2); + } + + @Override + public Response ltrimAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.ltrimAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni memory(List args) { + return redisAPI.memory(args); + } + + @Override + public Response memoryAndAwait(List args) { + return redisAPI.memoryAndAwait(args); + } + + @Override + public Uni mget(List args) { + return redisAPI.mget(args); + } + + @Override + public Response mgetAndAwait(List args) { + return redisAPI.mgetAndAwait(args); + } + + @Override + public Uni migrate(List args) { + return redisAPI.migrate(args); + } + + @Override + public Response migrateAndAwait(List args) { + return redisAPI.migrateAndAwait(args); + } + + @Override + public Uni module(List args) { + return redisAPI.module(args); + } + + @Override + public Response moduleAndAwait(List args) { + return redisAPI.moduleAndAwait(args); + } + + @Override + public Uni monitor() { + return redisAPI.monitor(); + } + + @Override + public Response monitorAndAwait() { + return redisAPI.monitorAndAwait(); + } + + @Override + public Uni move(String arg0, String arg1) { + return redisAPI.move(arg0, arg1); + } + + @Override + public Response moveAndAwait(String arg0, String arg1) { + return redisAPI.moveAndAwait(arg0, arg1); + } + + @Override + public Uni mset(List args) { + return redisAPI.mset(args); + } + + @Override + public Response msetAndAwait(List args) { + return redisAPI.msetAndAwait(args); + } + + @Override + public Uni msetnx(List args) { + return redisAPI.msetnx(args); + } + + @Override + public Response msetnxAndAwait(List args) { + return redisAPI.msetnxAndAwait(args); + } + + @Override + public Uni multi() { + return redisAPI.multi(); + } + + @Override + public Response multiAndAwait() { + return redisAPI.multiAndAwait(); + } + + @Override + public Uni object(List args) { + return redisAPI.object(args); + } + + @Override + public Response objectAndAwait(List args) { + return redisAPI.objectAndAwait(args); + } + + @Override + public Uni persist(String arg0) { + return redisAPI.persist(arg0); + } + + @Override + public Response persistAndAwait(String arg0) { + return redisAPI.persistAndAwait(arg0); + } + + @Override + public Uni pexpire(String arg0, String arg1) { + return redisAPI.pexpire(arg0, arg1); + } + + @Override + public Response pexpireAndAwait(String arg0, String arg1) { + return redisAPI.pexpireAndAwait(arg0, arg1); + } + + @Override + public Uni pexpireat(String arg0, String arg1) { + return redisAPI.pexpireat(arg0, arg1); + } + + @Override + public Response pexpireatAndAwait(String arg0, String arg1) { + return redisAPI.pexpireatAndAwait(arg0, arg1); + } + + @Override + public Uni pfadd(List args) { + return redisAPI.pfadd(args); + } + + @Override + public Response pfaddAndAwait(List args) { + return redisAPI.pfaddAndAwait(args); + } + + @Override + public Uni pfcount(List args) { + return redisAPI.pfcount(args); + } + + @Override + public Response pfcountAndAwait(List args) { + return redisAPI.pfcountAndAwait(args); + } + + @Override + public Uni pfdebug(List args) { + return redisAPI.pfdebug(args); + } + + @Override + public Response pfdebugAndAwait(List args) { + return redisAPI.pfdebugAndAwait(args); + } + + @Override + public Uni pfmerge(List args) { + return redisAPI.pfmerge(args); + } + + @Override + public Response pfmergeAndAwait(List args) { + return redisAPI.pfmergeAndAwait(args); + } + + @Override + public Uni pfselftest() { + return redisAPI.pfselftest(); + } + + @Override + public Response pfselftestAndAwait() { + return redisAPI.pfselftestAndAwait(); + } + + @Override + public Uni ping(List args) { + return redisAPI.ping(args); + } + + @Override + public Response pingAndAwait(List args) { + return redisAPI.pingAndAwait(args); + } + + @Override + public Uni post(List args) { + return redisAPI.post(args); + } + + @Override + public Response postAndAwait(List args) { + return redisAPI.postAndAwait(args); + } + + @Override + public Uni psetex(String arg0, String arg1, String arg2) { + return redisAPI.psetex(arg0, arg1, arg2); + } + + @Override + public Response psetexAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.psetexAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni psubscribe(List args) { + return redisAPI.psubscribe(args); + } + + @Override + public Response psubscribeAndAwait(List args) { + return redisAPI.psubscribeAndAwait(args); + } + + @Override + public Uni psync(String arg0, String arg1) { + return redisAPI.psync(arg0, arg1); + } + + @Override + public Response psyncAndAwait(String arg0, String arg1) { + return redisAPI.psyncAndAwait(arg0, arg1); + } + + @Override + public Uni pttl(String arg0) { + return redisAPI.pttl(arg0); + } + + @Override + public Response pttlAndAwait(String arg0) { + return redisAPI.pttlAndAwait(arg0); + } + + @Override + public Uni publish(String arg0, String arg1) { + return redisAPI.publish(arg0, arg1); + } + + @Override + public Response publishAndAwait(String arg0, String arg1) { + return redisAPI.publishAndAwait(arg0, arg1); + } + + @Override + public Uni pubsub(List args) { + return redisAPI.pubsub(args); + } + + @Override + public Response pubsubAndAwait(List args) { + return redisAPI.pubsubAndAwait(args); + } + + @Override + public Uni punsubscribe(List args) { + return redisAPI.punsubscribe(args); + } + + @Override + public Response punsubscribeAndAwait(List args) { + return redisAPI.punsubscribeAndAwait(args); + } + + @Override + public Uni randomkey() { + return redisAPI.randomkey(); + } + + @Override + public Response randomkeyAndAwait() { + return redisAPI.randomkeyAndAwait(); + } + + @Override + public Uni readonly() { + return redisAPI.readonly(); + } + + @Override + public Response readonlyAndAwait() { + return redisAPI.readonlyAndAwait(); + } + + @Override + public Uni readwrite() { + return redisAPI.readwrite(); + } + + @Override + public Response readwriteAndAwait() { + return redisAPI.readwriteAndAwait(); + } + + @Override + public Uni rename(String arg0, String arg1) { + return redisAPI.rename(arg0, arg1); + } + + @Override + public Response renameAndAwait(String arg0, String arg1) { + return redisAPI.renameAndAwait(arg0, arg1); + } + + @Override + public Uni renamenx(String arg0, String arg1) { + return redisAPI.renamenx(arg0, arg1); + } + + @Override + public Response renamenxAndAwait(String arg0, String arg1) { + return redisAPI.renamenxAndAwait(arg0, arg1); + } + + @Override + public Uni replconf(List args) { + return redisAPI.replconf(args); + } + + @Override + public Response replconfAndAwait(List args) { + return redisAPI.replconfAndAwait(args); + } + + @Override + public Uni replicaof(String arg0, String arg1) { + return redisAPI.replicaof(arg0, arg1); + } + + @Override + public Response replicaofAndAwait(String arg0, String arg1) { + return redisAPI.replicaofAndAwait(arg0, arg1); + } + + @Override + public Uni restore(List args) { + return redisAPI.restore(args); + } + + @Override + public Response restoreAndAwait(List args) { + return redisAPI.restoreAndAwait(args); + } + + @Override + public Uni restoreAsking(List args) { + return redisAPI.restoreAsking(args); + } + + @Override + public Response restoreAskingAndAwait(List args) { + return redisAPI.restoreAskingAndAwait(args); + } + + @Override + public Uni role() { + return redisAPI.role(); + } + + @Override + public Response roleAndAwait() { + return redisAPI.roleAndAwait(); + } + + @Override + public Uni rpop(String arg0) { + return redisAPI.rpop(arg0); + } + + @Override + public Response rpopAndAwait(String arg0) { + return redisAPI.rpopAndAwait(arg0); + } + + @Override + public Uni rpoplpush(String arg0, String arg1) { + return redisAPI.rpoplpush(arg0, arg1); + } + + @Override + public Response rpoplpushAndAwait(String arg0, String arg1) { + return redisAPI.rpoplpushAndAwait(arg0, arg1); + } + + @Override + public Uni rpush(List args) { + return redisAPI.rpush(args); + } + + @Override + public Response rpushAndAwait(List args) { + return redisAPI.rpushAndAwait(args); + } + + @Override + public Uni rpushx(List args) { + return redisAPI.rpushx(args); + } + + @Override + public Response rpushxAndAwait(List args) { + return redisAPI.rpushxAndAwait(args); + } + + @Override + public Uni sadd(List args) { + return redisAPI.sadd(args); + } + + @Override + public Response saddAndAwait(List args) { + return redisAPI.saddAndAwait(args); + } + + @Override + public Uni save() { + return redisAPI.save(); + } + + @Override + public Response saveAndAwait() { + return redisAPI.saveAndAwait(); + } + + @Override + public Uni scan(List args) { + return redisAPI.scan(args); + } + + @Override + public Response scanAndAwait(List args) { + return redisAPI.scanAndAwait(args); + } + + @Override + public Uni scard(String arg0) { + return redisAPI.scard(arg0); + } + + @Override + public Response scardAndAwait(String arg0) { + return redisAPI.scardAndAwait(arg0); + } + + @Override + public Uni script(List args) { + return redisAPI.script(args); + } + + @Override + public Response scriptAndAwait(List args) { + return redisAPI.scriptAndAwait(args); + } + + @Override + public Uni sdiff(List args) { + return redisAPI.sdiff(args); + } + + @Override + public Response sdiffAndAwait(List args) { + return redisAPI.sdiffAndAwait(args); + } + + @Override + public Uni sdiffstore(List args) { + return redisAPI.sdiffstore(args); + } + + @Override + public Response sdiffstoreAndAwait(List args) { + return redisAPI.sdiffstoreAndAwait(args); + } + + @Override + public Uni select(String arg0) { + return redisAPI.select(arg0); + } + + @Override + public Response selectAndAwait(String arg0) { + return redisAPI.selectAndAwait(arg0); + } + + @Override + public Uni set(List args) { + return redisAPI.set(args); + } + + @Override + public Response setAndAwait(List args) { + return redisAPI.setAndAwait(args); + } + + @Override + public Uni setbit(String arg0, String arg1, String arg2) { + return redisAPI.setbit(arg0, arg1, arg2); + } + + @Override + public Response setbitAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.setbitAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni setex(String arg0, String arg1, String arg2) { + return redisAPI.setex(arg0, arg1, arg2); + } + + @Override + public Response setexAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.setexAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni setnx(String arg0, String arg1) { + return redisAPI.setnx(arg0, arg1); + } + + @Override + public Response setnxAndAwait(String arg0, String arg1) { + return redisAPI.setnxAndAwait(arg0, arg1); + } + + @Override + public Uni setrange(String arg0, String arg1, String arg2) { + return redisAPI.setrange(arg0, arg1, arg2); + } + + @Override + public Response setrangeAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.setrangeAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni shutdown(List args) { + return redisAPI.shutdown(args); + } + + @Override + public Response shutdownAndAwait(List args) { + return redisAPI.shutdownAndAwait(args); + } + + @Override + public Uni sinter(List args) { + return redisAPI.sinter(args); + } + + @Override + public Response sinterAndAwait(List args) { + return redisAPI.sinterAndAwait(args); + } + + @Override + public Uni sinterstore(List args) { + return redisAPI.sinterstore(args); + } + + @Override + public Response sinterstoreAndAwait(List args) { + return redisAPI.sinterstoreAndAwait(args); + } + + @Override + public Uni sismember(String arg0, String arg1) { + return redisAPI.sismember(arg0, arg1); + } + + @Override + public Response sismemberAndAwait(String arg0, String arg1) { + return redisAPI.sismemberAndAwait(arg0, arg1); + } + + @Override + public Uni slaveof(String arg0, String arg1) { + return redisAPI.slaveof(arg0, arg1); + } + + @Override + public Response slaveofAndAwait(String arg0, String arg1) { + return redisAPI.slaveofAndAwait(arg0, arg1); + } + + @Override + public Uni slowlog(List args) { + return redisAPI.slowlog(args); + } + + @Override + public Response slowlogAndAwait(List args) { + return redisAPI.slowlogAndAwait(args); + } + + @Override + public Uni smembers(String arg0) { + return redisAPI.smembers(arg0); + } + + @Override + public Response smembersAndAwait(String arg0) { + return redisAPI.smembersAndAwait(arg0); + } + + @Override + public Uni smove(String arg0, String arg1, String arg2) { + return redisAPI.smove(arg0, arg1, arg2); + } + + @Override + public Response smoveAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.smoveAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni sort(List args) { + return redisAPI.sort(args); + } + + @Override + public Response sortAndAwait(List args) { + return redisAPI.sortAndAwait(args); + } + + @Override + public Uni spop(List args) { + return redisAPI.spop(args); + } + + @Override + public Response spopAndAwait(List args) { + return redisAPI.spopAndAwait(args); + } + + @Override + public Uni srandmember(List args) { + return redisAPI.srandmember(args); + } + + @Override + public Response srandmemberAndAwait(List args) { + return redisAPI.srandmemberAndAwait(args); + } + + @Override + public Uni srem(List args) { + return redisAPI.srem(args); + } + + @Override + public Response sremAndAwait(List args) { + return redisAPI.sremAndAwait(args); + } + + @Override + public Uni sscan(List args) { + return redisAPI.sscan(args); + } + + @Override + public Response sscanAndAwait(List args) { + return redisAPI.sscanAndAwait(args); + } + + @Override + public Uni strlen(String arg0) { + return redisAPI.strlen(arg0); + } + + @Override + public Response strlenAndAwait(String arg0) { + return redisAPI.strlenAndAwait(arg0); + } + + @Override + public Uni subscribe(List args) { + return redisAPI.subscribe(args); + } + + @Override + public Response subscribeAndAwait(List args) { + return redisAPI.subscribeAndAwait(args); + } + + @Override + public Uni substr(String arg0, String arg1, String arg2) { + return redisAPI.substr(arg0, arg1, arg2); + } + + @Override + public Response substrAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.substrAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni sunion(List args) { + return redisAPI.sunion(args); + } + + @Override + public Response sunionAndAwait(List args) { + return redisAPI.sunionAndAwait(args); + } + + @Override + public Uni sunionstore(List args) { + return redisAPI.sunionstore(args); + } + + @Override + public Response sunionstoreAndAwait(List args) { + return redisAPI.sunionstoreAndAwait(args); + } + + @Override + public Uni swapdb(String arg0, String arg1) { + return redisAPI.swapdb(arg0, arg1); + } + + @Override + public Response swapdbAndAwait(String arg0, String arg1) { + return redisAPI.swapdbAndAwait(arg0, arg1); + } + + @Override + public Uni sync() { + return redisAPI.sync(); + } + + @Override + public Response syncAndAwait() { + return redisAPI.syncAndAwait(); + } + + @Override + public Uni time() { + return redisAPI.time(); + } + + @Override + public Response timeAndAwait() { + return redisAPI.timeAndAwait(); + } + + @Override + public Uni touch(List args) { + return redisAPI.touch(args); + } + + @Override + public Response touchAndAwait(List args) { + return redisAPI.touchAndAwait(args); + } + + @Override + public Uni ttl(String arg0) { + return redisAPI.ttl(arg0); + } + + @Override + public Response ttlAndAwait(String arg0) { + return redisAPI.ttlAndAwait(arg0); + } + + @Override + public Uni type(String arg0) { + return redisAPI.type(arg0); + } + + @Override + public Response typeAndAwait(String arg0) { + return redisAPI.typeAndAwait(arg0); + } + + @Override + public Uni unlink(List args) { + return redisAPI.unlink(args); + } + + @Override + public Response unlinkAndAwait(List args) { + return redisAPI.unlinkAndAwait(args); + } + + @Override + public Uni unsubscribe(List args) { + return redisAPI.unsubscribe(args); + } + + @Override + public Response unsubscribeAndAwait(List args) { + return redisAPI.unsubscribeAndAwait(args); + } + + @Override + public Uni unwatch() { + return redisAPI.unwatch(); + } + + @Override + public Response unwatchAndAwait() { + return redisAPI.unwatchAndAwait(); + } + + @Override + public Uni wait(String arg0, String arg1) { + return redisAPI.wait(arg0, arg1); + } + + @Override + public Response waitAndAwait(String arg0, String arg1) { + return redisAPI.waitAndAwait(arg0, arg1); + } + + @Override + public Uni watch(List args) { + return redisAPI.watch(args); + } + + @Override + public Response watchAndAwait(List args) { + return redisAPI.watchAndAwait(args); + } + + @Override + public Uni xack(List args) { + return redisAPI.xack(args); + } + + @Override + public Response xackAndAwait(List args) { + return redisAPI.xackAndAwait(args); + } + + @Override + public Uni xadd(List args) { + return redisAPI.xadd(args); + } + + @Override + public Response xaddAndAwait(List args) { + return redisAPI.xaddAndAwait(args); + } + + @Override + public Uni xclaim(List args) { + return redisAPI.xclaim(args); + } + + @Override + public Response xclaimAndAwait(List args) { + return redisAPI.xclaimAndAwait(args); + } + + @Override + public Uni xdel(List args) { + return redisAPI.xdel(args); + } + + @Override + public Response xdelAndAwait(List args) { + return redisAPI.xdelAndAwait(args); + } + + @Override + public Uni xgroup(List args) { + return redisAPI.xgroup(args); + } + + @Override + public Response xgroupAndAwait(List args) { + return redisAPI.xgroupAndAwait(args); + } + + @Override + public Uni xinfo(List args) { + return redisAPI.xinfo(args); + } + + @Override + public Response xinfoAndAwait(List args) { + return redisAPI.xinfoAndAwait(args); + } + + @Override + public Uni xlen(String arg0) { + return redisAPI.xlen(arg0); + } + + @Override + public Response xlenAndAwait(String arg0) { + return redisAPI.xlenAndAwait(arg0); + } + + @Override + public Uni xpending(List args) { + return redisAPI.xpending(args); + } + + @Override + public Response xpendingAndAwait(List args) { + return redisAPI.xpendingAndAwait(args); + } + + @Override + public Uni xrange(List args) { + return redisAPI.xrange(args); + } + + @Override + public Response xrangeAndAwait(List args) { + return redisAPI.xrangeAndAwait(args); + } + + @Override + public Uni xread(List args) { + return redisAPI.xread(args); + } + + @Override + public Response xreadAndAwait(List args) { + return redisAPI.xreadAndAwait(args); + } + + @Override + public Uni xreadgroup(List args) { + return redisAPI.xreadgroup(args); + } + + @Override + public Response xreadgroupAndAwait(List args) { + return redisAPI.xreadgroupAndAwait(args); + } + + @Override + public Uni xrevrange(List args) { + return redisAPI.xrevrange(args); + } + + @Override + public Response xrevrangeAndAwait(List args) { + return redisAPI.xrevrangeAndAwait(args); + } + + @Override + public Uni xsetid(String arg0, String arg1) { + return redisAPI.xsetid(arg0, arg1); + } + + @Override + public Response xsetidAndAwait(String arg0, String arg1) { + return redisAPI.xsetidAndAwait(arg0, arg1); + } + + @Override + public Uni xtrim(List args) { + return redisAPI.xtrim(args); + } + + @Override + public Response xtrimAndAwait(List args) { + return redisAPI.xtrimAndAwait(args); + } + + @Override + public Uni zadd(List args) { + return redisAPI.zadd(args); + } + + @Override + public Response zaddAndAwait(List args) { + return redisAPI.zaddAndAwait(args); + } + + @Override + public Uni zcard(String arg0) { + return redisAPI.zcard(arg0); + } + + @Override + public Response zcardAndAwait(String arg0) { + return redisAPI.zcardAndAwait(arg0); + } + + @Override + public Uni zcount(String arg0, String arg1, String arg2) { + return redisAPI.zcount(arg0, arg1, arg2); + } + + @Override + public Response zcountAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.zcountAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni zincrby(String arg0, String arg1, String arg2) { + return redisAPI.zincrby(arg0, arg1, arg2); + } + + @Override + public Response zincrbyAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.zincrbyAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni zinterstore(List args) { + return redisAPI.zinterstore(args); + } + + @Override + public Response zinterstoreAndAwait(List args) { + return redisAPI.zinterstoreAndAwait(args); + } + + @Override + public Uni zlexcount(String arg0, String arg1, String arg2) { + return redisAPI.zlexcount(arg0, arg1, arg2); + } + + @Override + public Response zlexcountAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.zlexcountAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni zpopmax(List args) { + return redisAPI.zpopmax(args); + } + + @Override + public Response zpopmaxAndAwait(List args) { + return redisAPI.zpopmaxAndAwait(args); + } + + @Override + public Uni zpopmin(List args) { + return redisAPI.zpopmin(args); + } + + @Override + public Response zpopminAndAwait(List args) { + return redisAPI.zpopminAndAwait(args); + } + + @Override + public Uni zrange(List args) { + return redisAPI.zrange(args); + } + + @Override + public Response zrangeAndAwait(List args) { + return redisAPI.zrangeAndAwait(args); + } + + @Override + public Uni zrangebylex(List args) { + return redisAPI.zrangebylex(args); + } + + @Override + public Response zrangebylexAndAwait(List args) { + return redisAPI.zrangebylexAndAwait(args); + } + + @Override + public Uni zrangebyscore(List args) { + return redisAPI.zrangebyscore(args); + } + + @Override + public Response zrangebyscoreAndAwait(List args) { + return redisAPI.zrangebyscoreAndAwait(args); + } + + @Override + public Uni zrank(String arg0, String arg1) { + return redisAPI.zrank(arg0, arg1); + } + + @Override + public Response zrankAndAwait(String arg0, String arg1) { + return redisAPI.zrankAndAwait(arg0, arg1); + } + + @Override + public Uni zrem(List args) { + return redisAPI.zrem(args); + } + + @Override + public Response zremAndAwait(List args) { + return redisAPI.zremAndAwait(args); + } + + @Override + public Uni zremrangebylex(String arg0, String arg1, String arg2) { + return redisAPI.zremrangebylex(arg0, arg1, arg2); + } + + @Override + public Response zremrangebylexAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.zremrangebylexAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni zremrangebyrank(String arg0, String arg1, String arg2) { + return redisAPI.zremrangebyrank(arg0, arg1, arg2); + } + + @Override + public Response zremrangebyrankAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.zremrangebyrankAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni zremrangebyscore(String arg0, String arg1, String arg2) { + return redisAPI.zremrangebyscore(arg0, arg1, arg2); + } + + @Override + public Response zremrangebyscoreAndAwait(String arg0, String arg1, String arg2) { + return redisAPI.zremrangebyscoreAndAwait(arg0, arg1, arg2); + } + + @Override + public Uni zrevrange(List args) { + return redisAPI.zrevrange(args); + } + + @Override + public Response zrevrangeAndAwait(List args) { + return redisAPI.zrevrangeAndAwait(args); + } + + @Override + public Uni zrevrangebylex(List args) { + return redisAPI.zrevrangebylex(args); + } + + @Override + public Response zrevrangebylexAndAwait(List args) { + return redisAPI.zrevrangebylexAndAwait(args); + } + + @Override + public Uni zrevrangebyscore(List args) { + return redisAPI.zrevrangebyscore(args); + } + + @Override + public Response zrevrangebyscoreAndAwait(List args) { + return redisAPI.zrevrangebyscoreAndAwait(args); + } + + @Override + public Uni zrevrank(String arg0, String arg1) { + return redisAPI.zrevrank(arg0, arg1); + } + + @Override + public Response zrevrankAndAwait(String arg0, String arg1) { + return redisAPI.zrevrankAndAwait(arg0, arg1); + } + + @Override + public Uni zscan(List args) { + return redisAPI.zscan(args); + } + + @Override + public Response zscanAndAwait(List args) { + return redisAPI.zscanAndAwait(args); + } + + @Override + public Uni zscore(String arg0, String arg1) { + return redisAPI.zscore(arg0, arg1); + } + + @Override + public Response zscoreAndAwait(String arg0, String arg1) { + return redisAPI.zscoreAndAwait(arg0, arg1); + } + + @Override + public Uni zunionstore(List args) { + return redisAPI.zunionstore(args); + } + + @Override + public Response zunionstoreAndAwait(List args) { + return redisAPI.zunionstoreAndAwait(args); + } +} diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java new file mode 100644 index 0000000000000..5db2ce94b2216 --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisAPIProducer.java @@ -0,0 +1,136 @@ +package io.quarkus.redis.client.runtime; + +import java.net.InetSocketAddress; +import java.util.Set; + +import javax.annotation.PreDestroy; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +import javax.inject.Singleton; + +import io.quarkus.redis.client.RedisClient; +import io.quarkus.redis.client.reactive.ReactiveRedisClient; +import io.quarkus.runtime.configuration.ConfigurationException; +import io.vertx.core.Vertx; +import io.vertx.redis.client.Redis; +import io.vertx.redis.client.RedisAPI; +import io.vertx.redis.client.RedisClientType; +import io.vertx.redis.client.RedisOptions; + +@ApplicationScoped +class RedisAPIProducer { + private static final char AT = '@'; + private static final char COLON = ':'; + private static final char SLASH = '/'; + private static final String REDIS_SCHEME = "redis://"; + private static final String REDIS_SSL_SCHEME = "rediss://"; + + private long timeout = 10; + + private final RedisConfig config; + + private final Redis vertxRedisClient; + + private final RedisAPI redisAPI; + + private final RedisClient redisClient; + + private final ReactiveRedisClient reactiveClient; + + private final io.vertx.mutiny.redis.client.Redis mutinyRedisClient; + + private final io.vertx.mutiny.redis.client.RedisAPI mutinyRedisAPI; + + public RedisAPIProducer(RedisConfig config, Vertx vertx) { + this.config = config; + RedisOptions options = new RedisOptions(); + options.setType(config.clientType); + + if (RedisClientType.STANDALONE == config.clientType) { + if (config.hosts.isPresent() && config.hosts.get().size() > 1) { + throw new ConfigurationException("Multiple hosts supplied for non clustered configuration"); + } + } + + if (config.hosts.isPresent()) { + Set hosts = config.hosts.get(); + for (InetSocketAddress host : hosts) { + String connectionString = buildConnectionString(host); + options.addConnectionString(connectionString); + } + } else { + InetSocketAddress defaultRedisAddress = new InetSocketAddress("localhost", 6379); + String connectionString = buildConnectionString(defaultRedisAddress); + options.addConnectionString(connectionString); + } + + if (config.timeout.isPresent()) { + timeout = config.timeout.get().getSeconds(); + } + + vertxRedisClient = Redis.createClient(vertx, options); + redisAPI = RedisAPI.api(vertxRedisClient); + mutinyRedisClient = io.vertx.mutiny.redis.client.Redis.newInstance(vertxRedisClient); + mutinyRedisAPI = io.vertx.mutiny.redis.client.RedisAPI.api(mutinyRedisClient); + redisClient = new RedisClientImpl(mutinyRedisAPI, timeout); + reactiveClient = new ReactiveRedisClientImpl(mutinyRedisAPI); + } + + @Produces + @Singleton + Redis redis() { + return vertxRedisClient; + } + + @Produces + @Singleton + RedisAPI redisAPI() { + return redisAPI; + } + + @Produces + @Singleton + RedisClient redisClient() { + return redisClient; + } + + @Produces + @Singleton + ReactiveRedisClient reactiveRedisClient() { + return reactiveClient; + } + + @Produces + @Singleton + io.vertx.mutiny.redis.client.Redis mutinyRedisClient() { + return mutinyRedisClient; + } + + @Produces + @Singleton + io.vertx.mutiny.redis.client.RedisAPI mutinyRedisAPI() { + return mutinyRedisAPI; + } + + @PreDestroy + public void close() { + this.redis().close(); + } + + private String buildConnectionString(InetSocketAddress address) { + final StringBuilder builder = config.ssl ? new StringBuilder(REDIS_SSL_SCHEME) : new StringBuilder(REDIS_SCHEME); + + if (config.password.isPresent()) { + builder.append(config.password.get()); + builder.append(AT); + } + + builder.append(address.getHostString()); + builder.append(COLON); + builder.append(address.getPort()); + builder.append(SLASH); + builder.append(config.database); + + return builder.toString(); + } +} diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientImpl.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientImpl.java new file mode 100644 index 0000000000000..bb1f119610f8d --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisClientImpl.java @@ -0,0 +1,1028 @@ +package io.quarkus.redis.client.runtime; + +import java.time.Duration; +import java.util.List; + +import io.quarkus.redis.client.RedisClient; +import io.smallrye.mutiny.Uni; +import io.vertx.mutiny.redis.client.RedisAPI; +import io.vertx.redis.client.Response; + +class RedisClientImpl implements RedisClient { + private final RedisAPI redisAPI; + private final long timeout; + + public RedisClientImpl(RedisAPI redisAPI, long timeout) { + this.redisAPI = redisAPI; + this.timeout = timeout; + } + + @Override + public void close() { + redisAPI.close(); + } + + @Override + public Response append(String arg0, String arg1) { + return await(redisAPI.append(arg0, arg1)); + } + + @Override + public Response asking() { + return await(redisAPI.asking()); + } + + @Override + public Response auth(String arg0) { + return await(redisAPI.auth(arg0)); + } + + @Override + public Response bgrewriteaof() { + return await(redisAPI.bgrewriteaof()); + } + + @Override + public Response bgsave(List args) { + return await(redisAPI.bgsave(args)); + } + + @Override + public Response bitcount(List args) { + return await(redisAPI.bitcount(args)); + } + + @Override + public Response bitfield(List args) { + return await(redisAPI.bitfield(args)); + } + + @Override + public Response bitop(List args) { + return await(redisAPI.bitop(args)); + } + + @Override + public Response bitpos(List args) { + return await(redisAPI.bitpos(args)); + } + + @Override + public Response blpop(List args) { + return await(redisAPI.blpop(args)); + } + + @Override + public Response brpop(List args) { + return await(redisAPI.brpop(args)); + } + + @Override + public Response brpoplpush(String arg0, String arg1, String arg2) { + return await(redisAPI.brpoplpush(arg0, arg1, arg2)); + } + + @Override + public Response bzpopmax(List args) { + return await(redisAPI.bzpopmax(args)); + } + + @Override + public Response bzpopmin(List args) { + return await(redisAPI.bzpopmin(args)); + } + + @Override + public Response client(List args) { + return await(redisAPI.client(args)); + } + + @Override + public Response cluster(List args) { + return await(redisAPI.cluster(args)); + } + + @Override + public Response command() { + return await(redisAPI.command()); + } + + @Override + public Response config(List args) { + return await(redisAPI.config(args)); + } + + @Override + public Response dbsize() { + return await(redisAPI.dbsize()); + } + + @Override + public Response debug(List args) { + return await(redisAPI.debug(args)); + } + + @Override + public Response decr(String arg0) { + return await(redisAPI.decr(arg0)); + } + + @Override + public Response decrby(String arg0, String arg1) { + return await(redisAPI.decrby(arg0, arg1)); + } + + @Override + public Response del(List args) { + return await(redisAPI.del(args)); + } + + @Override + public Response discard() { + return await(redisAPI.discard()); + } + + @Override + public Response dump(String arg0) { + return await(redisAPI.dump(arg0)); + } + + @Override + public Response echo(String arg0) { + return await(redisAPI.echo(arg0)); + } + + @Override + public Response eval(List args) { + return await(redisAPI.eval(args)); + } + + @Override + public Response evalsha(List args) { + return await(redisAPI.evalsha(args)); + } + + @Override + public Response exec() { + return await(redisAPI.exec()); + } + + @Override + public Response exists(List args) { + return await(redisAPI.exists(args)); + } + + @Override + public Response expire(String arg0, String arg1) { + return await(redisAPI.expire(arg0, arg1)); + } + + @Override + public Response expireat(String arg0, String arg1) { + return await(redisAPI.expireat(arg0, arg1)); + } + + @Override + public Response flushall(List args) { + return await(redisAPI.flushall(args)); + } + + @Override + public Response flushdb(List args) { + return await(redisAPI.flushdb(args)); + } + + @Override + public Response geoadd(List args) { + return await(redisAPI.geoadd(args)); + } + + @Override + public Response geodist(List args) { + return await(redisAPI.geodist(args)); + } + + @Override + public Response geohash(List args) { + return await(redisAPI.geohash(args)); + } + + @Override + public Response geopos(List args) { + return await(redisAPI.geopos(args)); + } + + @Override + public Response georadius(List args) { + return await(redisAPI.georadius(args)); + } + + @Override + public Response georadiusRo(List args) { + return await(redisAPI.georadiusRo(args)); + } + + @Override + public Response georadiusbymember(List args) { + return await(redisAPI.georadiusbymember(args)); + } + + @Override + public Response georadiusbymemberRo(List args) { + return await(redisAPI.georadiusbymemberRo(args)); + } + + @Override + public Response get(String arg0) { + return await(redisAPI.get(arg0)); + } + + @Override + public Response getbit(String arg0, String arg1) { + return await(redisAPI.getbit(arg0, arg1)); + } + + @Override + public Response getrange(String arg0, String arg1, String arg2) { + return await(redisAPI.getrange(arg0, arg1, arg2)); + } + + @Override + public Response getset(String arg0, String arg1) { + return await(redisAPI.getset(arg0, arg1)); + } + + @Override + public Response hdel(List args) { + return await(redisAPI.hdel(args)); + } + + @Override + public Response hexists(String arg0, String arg1) { + return await(redisAPI.hexists(arg0, arg1)); + } + + @Override + public Response hget(String arg0, String arg1) { + return await(redisAPI.hget(arg0, arg1)); + } + + @Override + public Response hgetall(String arg0) { + return await(redisAPI.hgetall(arg0)); + } + + @Override + public Response hincrby(String arg0, String arg1, String arg2) { + return await(redisAPI.hincrby(arg0, arg1, arg2)); + } + + @Override + public Response hincrbyfloat(String arg0, String arg1, String arg2) { + return await(redisAPI.hincrbyfloat(arg0, arg1, arg2)); + } + + @Override + public Response hkeys(String arg0) { + return await(redisAPI.hkeys(arg0)); + } + + @Override + public Response hlen(String arg0) { + return await(redisAPI.hlen(arg0)); + } + + @Override + public Response hmget(List args) { + return await(redisAPI.hmget(args)); + } + + @Override + public Response hmset(List args) { + return await(redisAPI.hmset(args)); + } + + @Override + public Response host(List args) { + return await(redisAPI.host(args)); + } + + @Override + public Response hscan(List args) { + return await(redisAPI.hscan(args)); + } + + @Override + public Response hset(List args) { + return await(redisAPI.hset(args)); + } + + @Override + public Response hsetnx(String arg0, String arg1, String arg2) { + return await(redisAPI.hsetnx(arg0, arg1, arg2)); + } + + @Override + public Response hstrlen(String arg0, String arg1) { + return await(redisAPI.hstrlen(arg0, arg1)); + } + + @Override + public Response hvals(String arg0) { + return await(redisAPI.hvals(arg0)); + } + + @Override + public Response incr(String arg0) { + return await(redisAPI.incr(arg0)); + } + + @Override + public Response incrby(String arg0, String arg1) { + return await(redisAPI.incrby(arg0, arg1)); + } + + @Override + public Response incrbyfloat(String arg0, String arg1) { + return await(redisAPI.incrbyfloat(arg0, arg1)); + } + + @Override + public Response info(List args) { + return await(redisAPI.info(args)); + } + + @Override + public Response keys(String arg0) { + return await(redisAPI.keys(arg0)); + } + + @Override + public Response lastsave() { + return await(redisAPI.lastsave()); + } + + @Override + public Response latency(List args) { + return await(redisAPI.latency(args)); + } + + @Override + public Response lindex(String arg0, String arg1) { + return await(redisAPI.lindex(arg0, arg1)); + } + + @Override + public Response linsert(String arg0, String arg1, String arg2, String arg3) { + return await(redisAPI.linsert(arg0, arg1, arg2, arg3)); + } + + @Override + public Response llen(String arg0) { + return await(redisAPI.llen(arg0)); + } + + @Override + public Response lolwut(List args) { + return await(redisAPI.lolwut(args)); + } + + @Override + public Response lpop(String arg0) { + return await(redisAPI.lpop(arg0)); + } + + @Override + public Response lpush(List args) { + return await(redisAPI.lpush(args)); + } + + @Override + public Response lpushx(List args) { + return await(redisAPI.lpushx(args)); + } + + @Override + public Response lrange(String arg0, String arg1, String arg2) { + return await(redisAPI.lrange(arg0, arg1, arg2)); + } + + @Override + public Response lrem(String arg0, String arg1, String arg2) { + return await(redisAPI.lrem(arg0, arg1, arg2)); + } + + @Override + public Response lset(String arg0, String arg1, String arg2) { + return await(redisAPI.lset(arg0, arg1, arg2)); + } + + @Override + public Response ltrim(String arg0, String arg1, String arg2) { + return await(redisAPI.ltrim(arg0, arg1, arg2)); + } + + @Override + public Response memory(List args) { + return await(redisAPI.memory(args)); + } + + @Override + public Response mget(List args) { + return await(redisAPI.mget(args)); + } + + @Override + public Response migrate(List args) { + return await(redisAPI.migrate(args)); + } + + @Override + public Response module(List args) { + return await(redisAPI.module(args)); + } + + @Override + public Response monitor() { + return await(redisAPI.monitor()); + } + + @Override + public Response move(String arg0, String arg1) { + return await(redisAPI.move(arg0, arg1)); + } + + @Override + public Response mset(List args) { + return await(redisAPI.mset(args)); + } + + @Override + public Response msetnx(List args) { + return await(redisAPI.msetnx(args)); + } + + @Override + public Response multi() { + return await(redisAPI.multi()); + } + + @Override + public Response object(List args) { + return await(redisAPI.object(args)); + } + + @Override + public Response persist(String arg0) { + return await(redisAPI.persist(arg0)); + } + + @Override + public Response pexpire(String arg0, String arg1) { + return await(redisAPI.pexpire(arg0, arg1)); + } + + @Override + public Response pexpireat(String arg0, String arg1) { + return await(redisAPI.pexpireat(arg0, arg1)); + } + + @Override + public Response pfadd(List args) { + return await(redisAPI.pfadd(args)); + } + + @Override + public Response pfcount(List args) { + return await(redisAPI.pfcount(args)); + } + + @Override + public Response pfdebug(List args) { + return await(redisAPI.pfdebug(args)); + } + + @Override + public Response pfmerge(List args) { + return await(redisAPI.pfmerge(args)); + } + + @Override + public Response pfselftest() { + return await(redisAPI.pfselftest()); + } + + @Override + public Response ping(List args) { + return await(redisAPI.ping(args)); + } + + @Override + public Response post(List args) { + return await(redisAPI.post(args)); + } + + @Override + public Response psetex(String arg0, String arg1, String arg2) { + return await(redisAPI.psetex(arg0, arg1, arg2)); + } + + @Override + public Response psubscribe(List args) { + return await(redisAPI.psubscribe(args)); + } + + @Override + public Response psync(String arg0, String arg1) { + return await(redisAPI.psync(arg0, arg1)); + } + + @Override + public Response pttl(String arg0) { + return await(redisAPI.pttl(arg0)); + } + + @Override + public Response publish(String arg0, String arg1) { + return await(redisAPI.publish(arg0, arg1)); + } + + @Override + public Response pubsub(List args) { + return await(redisAPI.pubsub(args)); + } + + @Override + public Response punsubscribe(List args) { + return await(redisAPI.punsubscribe(args)); + } + + @Override + public Response randomkey() { + return await(redisAPI.randomkey()); + } + + @Override + public Response readonly() { + return await(redisAPI.readonly()); + } + + @Override + public Response readwrite() { + return await(redisAPI.readwrite()); + } + + @Override + public Response rename(String arg0, String arg1) { + return await(redisAPI.rename(arg0, arg1)); + } + + @Override + public Response renamenx(String arg0, String arg1) { + return await(redisAPI.renamenx(arg0, arg1)); + } + + @Override + public Response replconf(List args) { + return await(redisAPI.replconf(args)); + } + + @Override + public Response replicaof(String arg0, String arg1) { + return await(redisAPI.replicaof(arg0, arg1)); + } + + @Override + public Response restore(List args) { + return await(redisAPI.restore(args)); + } + + @Override + public Response restoreAsking(List args) { + return await(redisAPI.restoreAsking(args)); + } + + @Override + public Response role() { + return await(redisAPI.role()); + } + + @Override + public Response rpop(String arg0) { + return await(redisAPI.rpop(arg0)); + } + + @Override + public Response rpoplpush(String arg0, String arg1) { + return await(redisAPI.rpoplpush(arg0, arg1)); + } + + @Override + public Response rpush(List args) { + return await(redisAPI.rpush(args)); + } + + @Override + public Response rpushx(List args) { + return await(redisAPI.rpushx(args)); + } + + @Override + public Response sadd(List args) { + return await(redisAPI.sadd(args)); + } + + @Override + public Response save() { + return await(redisAPI.save()); + } + + @Override + public Response scan(List args) { + return await(redisAPI.scan(args)); + } + + @Override + public Response scard(String arg0) { + return await(redisAPI.scard(arg0)); + } + + @Override + public Response script(List args) { + return await(redisAPI.script(args)); + } + + @Override + public Response sdiff(List args) { + return await(redisAPI.sdiff(args)); + } + + @Override + public Response sdiffstore(List args) { + return await(redisAPI.sdiffstore(args)); + } + + @Override + public Response select(String arg0) { + return await(redisAPI.select(arg0)); + } + + @Override + public Response set(List args) { + return await(redisAPI.set(args)); + } + + @Override + public Response setbit(String arg0, String arg1, String arg2) { + return await(redisAPI.setbit(arg0, arg1, arg2)); + } + + @Override + public Response setex(String arg0, String arg1, String arg2) { + return await(redisAPI.setex(arg0, arg1, arg2)); + } + + @Override + public Response setnx(String arg0, String arg1) { + return await(redisAPI.setnx(arg0, arg1)); + } + + @Override + public Response setrange(String arg0, String arg1, String arg2) { + return await(redisAPI.setrange(arg0, arg1, arg2)); + } + + @Override + public Response shutdown(List args) { + return await(redisAPI.shutdown(args)); + } + + @Override + public Response sinter(List args) { + return await(redisAPI.sinter(args)); + } + + @Override + public Response sinterstore(List args) { + return await(redisAPI.sinterstore(args)); + } + + @Override + public Response sismember(String arg0, String arg1) { + return await(redisAPI.sismember(arg0, arg1)); + } + + @Override + public Response slaveof(String arg0, String arg1) { + return await(redisAPI.slaveof(arg0, arg1)); + } + + @Override + public Response slowlog(List args) { + return await(redisAPI.slowlog(args)); + } + + @Override + public Response smembers(String arg0) { + return await(redisAPI.smembers(arg0)); + } + + @Override + public Response smove(String arg0, String arg1, String arg2) { + return await(redisAPI.smove(arg0, arg1, arg2)); + } + + @Override + public Response sort(List args) { + return await(redisAPI.sort(args)); + } + + @Override + public Response spop(List args) { + return await(redisAPI.spop(args)); + } + + @Override + public Response srandmember(List args) { + return await(redisAPI.srandmember(args)); + } + + @Override + public Response srem(List args) { + return await(redisAPI.srem(args)); + } + + @Override + public Response sscan(List args) { + return await(redisAPI.sscan(args)); + } + + @Override + public Response strlen(String arg0) { + return await(redisAPI.strlen(arg0)); + } + + @Override + public Response subscribe(List args) { + return await(redisAPI.subscribe(args)); + } + + @Override + public Response substr(String arg0, String arg1, String arg2) { + return await(redisAPI.substr(arg0, arg1, arg2)); + } + + @Override + public Response sunion(List args) { + return await(redisAPI.sunion(args)); + } + + @Override + public Response sunionstore(List args) { + return await(redisAPI.sunionstore(args)); + } + + @Override + public Response swapdb(String arg0, String arg1) { + return await(redisAPI.swapdb(arg0, arg1)); + } + + @Override + public Response sync() { + return await(redisAPI.sync()); + } + + @Override + public Response time() { + return await(redisAPI.time()); + } + + @Override + public Response touch(List args) { + return await(redisAPI.touch(args)); + } + + @Override + public Response ttl(String arg0) { + return await(redisAPI.ttl(arg0)); + } + + @Override + public Response type(String arg0) { + return await(redisAPI.type(arg0)); + } + + @Override + public Response unlink(List args) { + return await(redisAPI.unlink(args)); + } + + @Override + public Response unsubscribe(List args) { + return await(redisAPI.unsubscribe(args)); + } + + @Override + public Response unwatch() { + return await(redisAPI.unwatch()); + } + + @Override + public Response wait(String arg0, String arg1) { + return await(redisAPI.wait(arg0, arg1)); + } + + @Override + public Response watch(List args) { + return await(redisAPI.watch(args)); + } + + @Override + public Response xack(List args) { + return await(redisAPI.xack(args)); + } + + @Override + public Response xadd(List args) { + return await(redisAPI.xadd(args)); + } + + @Override + public Response xclaim(List args) { + return await(redisAPI.xclaim(args)); + } + + @Override + public Response xdel(List args) { + return await(redisAPI.xdel(args)); + } + + @Override + public Response xgroup(List args) { + return await(redisAPI.xgroup(args)); + } + + @Override + public Response xinfo(List args) { + return await(redisAPI.xinfo(args)); + } + + @Override + public Response xlen(String arg0) { + return await(redisAPI.xlen(arg0)); + } + + @Override + public Response xpending(List args) { + return await(redisAPI.xpending(args)); + } + + @Override + public Response xrange(List args) { + return await(redisAPI.xrange(args)); + } + + @Override + public Response xread(List args) { + return await(redisAPI.xread(args)); + } + + @Override + public Response xreadgroup(List args) { + return await(redisAPI.xreadgroup(args)); + } + + @Override + public Response xrevrange(List args) { + return await(redisAPI.xrevrange(args)); + } + + @Override + public Response xsetid(String arg0, String arg1) { + return await(redisAPI.xsetid(arg0, arg1)); + } + + @Override + public Response xtrim(List args) { + return await(redisAPI.xtrim(args)); + } + + @Override + public Response zadd(List args) { + return await(redisAPI.zadd(args)); + } + + @Override + public Response zcard(String arg0) { + return await(redisAPI.zcard(arg0)); + } + + @Override + public Response zcount(String arg0, String arg1, String arg2) { + return await(redisAPI.zcount(arg0, arg1, arg2)); + } + + @Override + public Response zincrby(String arg0, String arg1, String arg2) { + return await(redisAPI.zincrby(arg0, arg1, arg2)); + } + + @Override + public Response zinterstore(List args) { + return await(redisAPI.zinterstore(args)); + } + + @Override + public Response zlexcount(String arg0, String arg1, String arg2) { + return await(redisAPI.zlexcount(arg0, arg1, arg2)); + } + + @Override + public Response zpopmax(List args) { + return await(redisAPI.zpopmax(args)); + } + + @Override + public Response zpopmin(List args) { + return await(redisAPI.zpopmin(args)); + } + + @Override + public Response zrange(List args) { + return await(redisAPI.zrange(args)); + } + + @Override + public Response zrangebylex(List args) { + return await(redisAPI.zrangebylex(args)); + } + + @Override + public Response zrangebyscore(List args) { + return await(redisAPI.zrangebyscore(args)); + } + + @Override + public Response zrank(String arg0, String arg1) { + return await(redisAPI.zrank(arg0, arg1)); + } + + @Override + public Response zrem(List args) { + return await(redisAPI.zrem(args)); + } + + @Override + public Response zremrangebylex(String arg0, String arg1, String arg2) { + return await(redisAPI.zremrangebylex(arg0, arg1, arg2)); + } + + @Override + public Response zremrangebyrank(String arg0, String arg1, String arg2) { + return await(redisAPI.zremrangebyrank(arg0, arg1, arg2)); + } + + @Override + public Response zremrangebyscore(String arg0, String arg1, String arg2) { + return await(redisAPI.zremrangebyscore(arg0, arg1, arg2)); + } + + @Override + public Response zrevrange(List args) { + return await(redisAPI.zrevrange(args)); + } + + @Override + public Response zrevrangebylex(List args) { + return await(redisAPI.zrevrangebylex(args)); + } + + @Override + public Response zrevrangebyscore(List args) { + return await(redisAPI.zrevrangebyscore(args)); + } + + @Override + public Response zrevrank(String arg0, String arg1) { + return await(redisAPI.zrevrank(arg0, arg1)); + } + + @Override + public Response zscan(List args) { + return await(redisAPI.zscan(args)); + } + + @Override + public Response zscore(String arg0, String arg1) { + return await(redisAPI.zscore(arg0, arg1)); + } + + @Override + public Response zunionstore(List args) { + return await(redisAPI.zunionstore(args)); + } + + private Response await(Uni mutinyResponse) { + return mutinyResponse.await().atMost(Duration.ofSeconds(timeout)).getDelegate(); + } +} diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java new file mode 100644 index 0000000000000..321ff1a26e9c7 --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/RedisConfig.java @@ -0,0 +1,51 @@ +package io.quarkus.redis.client.runtime; + +import java.net.InetSocketAddress; +import java.time.Duration; +import java.util.Optional; +import java.util.Set; + +import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigPhase; +import io.quarkus.runtime.annotations.ConfigRoot; +import io.vertx.redis.client.RedisClientType; + +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +public class RedisConfig { + + /** + * The redis password + */ + @ConfigItem + public Optional password; + + /** + * The redis hosts + */ + @ConfigItem(defaultValue = "localhost:6379") + public Optional> hosts; + + /** + * The redis database + */ + @ConfigItem + public int database; + + /** + * The maximum delay to wait before a blocking command to redis server times out + */ + @ConfigItem(defaultValue = "10s") + public Optional timeout; + + /** + * Enables or disables the SSL on connect. + */ + @ConfigItem + public boolean ssl; + + /** + * The redis client type + */ + @ConfigItem(defaultValue = "standalone") + public RedisClientType clientType; +} diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/health/RedisHealthCheck.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/health/RedisHealthCheck.java new file mode 100644 index 0000000000000..d8b23e679c666 --- /dev/null +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/client/runtime/health/RedisHealthCheck.java @@ -0,0 +1,36 @@ +package io.quarkus.redis.client.runtime.health; + +import java.util.Collections; + +import javax.enterprise.context.ApplicationScoped; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.HealthCheckResponseBuilder; +import org.eclipse.microprofile.health.Readiness; + +import io.quarkus.arc.Arc; +import io.quarkus.arc.InstanceHandle; +import io.quarkus.redis.client.RedisClient; + +@Readiness +@ApplicationScoped +class RedisHealthCheck implements HealthCheck { + + @Override + public HealthCheckResponse call() { + HealthCheckResponseBuilder builder = HealthCheckResponse.named("Redis connection health check").up(); + + try (InstanceHandle instanceHandle = Arc.container().instance(RedisClient.class)) { + if (!instanceHandle.isAvailable()) { + builder.down(); + } else { + RedisClient redisAPI = instanceHandle.get(); + redisAPI.ping(Collections.emptyList()); + } + } catch (RuntimeException e) { + builder.down(); + } + return builder.build(); + } +} diff --git a/extensions/redis-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/redis-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000000..f822f8cb2d9ac --- /dev/null +++ b/extensions/redis-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,15 @@ +--- +name: "Redis Client" +metadata: + keywords: + - "redis" + - "redis-client" + - "vertx-redis" + - "vertx" + - "vert.x" + - "reactive" + guide: "https://quarkus.io/guides/redis" + categories: + - "persistence" + - "reactive" + status: "preview" diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 3f76c1e58d24a..da2de0125856d 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -107,6 +107,7 @@ smallrye-graphql jpa-without-entity quartz + redis-client logging-gelf cache qute diff --git a/integration-tests/redis-client/README.md b/integration-tests/redis-client/README.md new file mode 100644 index 0000000000000..d943e88df2ca1 --- /dev/null +++ b/integration-tests/redis-client/README.md @@ -0,0 +1,21 @@ +# Redis example + +## Running the tests + +By default, the tests of this module are disabled. + +To run, you can run the following command: + +``` +mvn clean install -Dtest-redis +``` + +NB: Tests in this module will attempt a connection to a local Redis listening on the default port. +If you have specific requirements, you can define a specific connection URL with `-Dquarkus.redis.hosts=host:port`. + + +Additionally, you can generate a native image and run the tests for this native image by adding `-Dnative`: + +``` +mvn clean install -Dtest-redis -Dnative +``` diff --git a/integration-tests/redis-client/pom.xml b/integration-tests/redis-client/pom.xml new file mode 100644 index 0000000000000..95e8ebe403163 --- /dev/null +++ b/integration-tests/redis-client/pom.xml @@ -0,0 +1,154 @@ + + + 4.0.0 + + io.quarkus + quarkus-integration-tests-parent + 999-SNAPSHOT + ../pom.xml + + + redis-client-integration-test + Quarkus - Redis Client - Integration Test + + + localhost:6379 + + + + + io.quarkus + quarkus-resteasy-mutiny + + + io.quarkus + quarkus-redis-client + + + io.quarkus + quarkus-smallrye-health + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + + src/main/resources + true + + + + + maven-surefire-plugin + + true + + + + maven-failsafe-plugin + + true + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + + + + + test-redis + + + test-redis + + + + + + maven-surefire-plugin + + false + + + + maven-failsafe-plugin + + false + + + + + + + + native-image + + + native + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + + + + + + + io.quarkus + quarkus-maven-plugin + + + native-image + + native-image + + + true + true + ${graalvmHome} + -H:+TraceClassInitialization + + + + + + + + + + diff --git a/integration-tests/redis-client/src/main/java/io/quarkus/redis/it/RedisResource.java b/integration-tests/redis-client/src/main/java/io/quarkus/redis/it/RedisResource.java new file mode 100644 index 0000000000000..e59101e6ae2ce --- /dev/null +++ b/integration-tests/redis-client/src/main/java/io/quarkus/redis/it/RedisResource.java @@ -0,0 +1,55 @@ +package io.quarkus.redis.it; + +import java.util.Arrays; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +import io.quarkus.redis.client.RedisClient; +import io.quarkus.redis.client.reactive.ReactiveRedisClient; +import io.smallrye.mutiny.Uni; + +@Path("/quarkus-redis") +@ApplicationScoped +public class RedisResource { + @Inject + RedisClient redisClient; + + @Inject + ReactiveRedisClient reactiveRedisClient; + + // synchronous + @GET + @Path("/sync/{key}") + public String getSync(@PathParam("key") String key) { + return redisClient.get(key).toString(); + } + + @POST + @Path("/sync/{key}") + public void setSync(@PathParam("key") String key, String value) { + this.redisClient.set(Arrays.asList(key, value)); + } + + // reactive + @GET + @Path("/reactive/{key}") + public Uni getReactive(@PathParam("key") String key) { + return reactiveRedisClient + .get(key) + .map(response -> response.toString()); + } + + @POST + @Path("/reactive/{key}") + public Uni setReactive(@PathParam("key") String key, String value) { + return this.reactiveRedisClient + .set(Arrays.asList(key, value)) + .map(response -> null); + } + +} diff --git a/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/HealthCheckIT.java b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/HealthCheckIT.java new file mode 100644 index 0000000000000..47b6c577b65f1 --- /dev/null +++ b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/HealthCheckIT.java @@ -0,0 +1,7 @@ +package io.quarkus.redis.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class HealthCheckIT extends HealthCheckTest { +} diff --git a/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/HealthCheckTest.java b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/HealthCheckTest.java new file mode 100644 index 0000000000000..c3c424056d424 --- /dev/null +++ b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/HealthCheckTest.java @@ -0,0 +1,24 @@ +package io.quarkus.redis.it; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsInAnyOrder; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +@QuarkusTest +public class HealthCheckTest { + @Test + public void testHealthCheck() { + RestAssured.when().get("/health").then() + .contentType(ContentType.JSON) + .header("Content-Type", containsString("charset=UTF-8")) + .body("status", is("UP"), + "checks.status", containsInAnyOrder("UP"), + "checks.name", containsInAnyOrder("Redis connection health check")); + } +} diff --git a/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/QuarkusRedisIT.java b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/QuarkusRedisIT.java new file mode 100644 index 0000000000000..863cdd381a3bb --- /dev/null +++ b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/QuarkusRedisIT.java @@ -0,0 +1,8 @@ +package io.quarkus.redis.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class QuarkusRedisIT extends QuarkusRedisTest { + +} diff --git a/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/QuarkusRedisTest.java b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/QuarkusRedisTest.java new file mode 100644 index 0000000000000..2c407bab66bb9 --- /dev/null +++ b/integration-tests/redis-client/src/test/java/io/quarkus/redis/it/QuarkusRedisTest.java @@ -0,0 +1,50 @@ +package io.quarkus.redis.it; + +import org.hamcrest.CoreMatchers; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; + +@QuarkusTest +class QuarkusRedisTest { + private static final String SYNC_KEY = "sync-key"; + private static final String SYNC_VALUE = "sync-value"; + + private static final String REACTIVE_KEY = "reactive-key"; + private static final String REACTIVE_VALUE = "reactive-value"; + + @Test + public void sync() { + RestAssured.given() + .body(SYNC_VALUE) + .when() + .post("/quarkus-redis/sync/" + SYNC_KEY) + .then() + .statusCode(204); + + RestAssured.given() + .when() + .get("/quarkus-redis/sync/" + SYNC_KEY) + .then() + .statusCode(200) + .body(CoreMatchers.is(SYNC_VALUE)); + } + + @Test + public void reactive() { + RestAssured.given() + .body(REACTIVE_VALUE) + .when() + .post("/quarkus-redis/reactive/" + REACTIVE_KEY) + .then() + .statusCode(204); + + RestAssured.given() + .when() + .get("/quarkus-redis/reactive/" + REACTIVE_KEY) + .then() + .statusCode(200) + .body(CoreMatchers.is(REACTIVE_VALUE)); + } +}