Skip to content

Commit

Permalink
WIP Add support for Vert.x Web sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Oct 16, 2023
1 parent fae06ac commit 45480f2
Show file tree
Hide file tree
Showing 31 changed files with 942 additions and 5 deletions.
20 changes: 20 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,16 @@
<artifactId>quarkus-infinispan-client-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaeger</artifactId>
Expand Down Expand Up @@ -5966,6 +5976,11 @@
<artifactId>quarkus-redis-client-runtime-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-cache</artifactId>
Expand All @@ -5982,6 +5997,11 @@
<artifactId>quarkus-redis-client-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-cache-deployment</artifactId>
Expand Down
26 changes: 26 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-info</artifactId>
Expand Down Expand Up @@ -1838,6 +1851,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
Expand Down
26 changes: 26 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-info-deployment</artifactId>
Expand Down Expand Up @@ -1854,6 +1867,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-deployment</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions extensions/infinispan-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
<module>deployment-spi</module>
<module>runtime</module>
<module>runtime-spi</module>

<module>sessions/deployment</module>
<module>sessions/runtime</module>
</modules>
</project>
5 changes: 5 additions & 0 deletions extensions/infinispan-client/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
<artifactId>quarkus-kubernetes-service-binding</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
Expand Down
52 changes: 52 additions & 0 deletions extensions/infinispan-client/sessions/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>quarkus-infinispan-client-sessions-deployment</artifactId>

<name>Quarkus - Infinispan Client - Vert.x Web Sessions - Deployment</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-deployment-spi</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.quarkus.infinispan.sessions.deployment;

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

/**
* Configuration of Vert.x Web sessions stored in remote Infinispan cache.
*/
@ConfigRoot(name = "http.sessions.infinispan", phase = ConfigPhase.BUILD_TIME)
public class InfinispanSessionsBuildTimeConfig {
/**
* Name of the Infinispan client configured in the Quarkus Infinispan Client extension configuration.
* If not set, uses the default (unnamed) Infinispan client.
* <p>
* Note that the Infinispan client must be configured to so that the user has necessary permissions
* on the Infinispan server. The required minimum is the Infinispan {@code deployer} role.
*/
@ConfigItem
public Optional<String> clientName;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.quarkus.infinispan.sessions.deployment;

import java.util.List;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.infinispan.client.deployment.spi.InfinispanClientBuildItem;
import io.quarkus.infinispan.client.deployment.spi.InfinispanClientNameBuildItem;
import io.quarkus.infinispan.client.runtime.spi.InfinispanConstants;
import io.quarkus.infinispan.sessions.runtime.InfinispanSessionsRecorder;
import io.quarkus.vertx.http.deployment.SessionStoreProviderBuildItem;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
import io.quarkus.vertx.http.runtime.SessionsBuildTimeConfig;

public class InfinispanSessionsProcessor {
@BuildStep
public void infinispanClients(HttpBuildTimeConfig httpConfig,
InfinispanSessionsBuildTimeConfig config,
BuildProducer<InfinispanClientNameBuildItem> infinispanRequest) {
if (httpConfig.sessions.mode == SessionsBuildTimeConfig.SessionsMode.INFINISPAN) {
String clientName = config.clientName.orElse(InfinispanConstants.DEFAULT_INFINISPAN_CLIENT_NAME);
infinispanRequest.produce(new InfinispanClientNameBuildItem(clientName));
}
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void infinispanSessions(HttpBuildTimeConfig httpConfig,
InfinispanSessionsBuildTimeConfig config,
List<InfinispanClientBuildItem> clients,
BuildProducer<SessionStoreProviderBuildItem> provider,
InfinispanSessionsRecorder recorder) {
if (httpConfig.sessions.mode == SessionsBuildTimeConfig.SessionsMode.INFINISPAN) {
String clientName = config.clientName.orElse(InfinispanConstants.DEFAULT_INFINISPAN_CLIENT_NAME);
for (InfinispanClientBuildItem infinispanClient : clients) {
if (clientName.equals(infinispanClient.getName())) {
provider.produce(new SessionStoreProviderBuildItem(recorder.create(infinispanClient.getClient())));
return;
}
}
throw new IllegalStateException("Unknown Infinispan client: " + clientName);
}
}
}
85 changes: 85 additions & 0 deletions extensions/infinispan-client/sessions/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>quarkus-infinispan-client-sessions</artifactId>

<name>Quarkus - Infinispan Client - Vert.x Web Sessions - Runtime</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-sstore-infinispan</artifactId>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-client-hotrod</artifactId>
</exclusion>
<exclusion>
<groupId>io.reactivex.rxjava3</groupId>
<artifactId>rxjava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-client-hotrod-jakarta</artifactId>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-jboss-marshalling</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<configuration>
<dependencyCondition>
<artifact>io.quarkus:quarkus-vertx-http</artifact>
</dependencyCondition>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.infinispan.sessions.runtime;

import java.time.Duration;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

/**
* Configuration of Vert.x Web sessions stored in remote Infinispan cache.
*/
@ConfigRoot(name = "http.sessions.infinispan", phase = ConfigPhase.RUN_TIME)
public class InfinispanSessionsConfig {
/**
* Name of the Infinispan cache used to store session data. If it does not exist, it is created
* automatically from Infinispan's default template {@code DIST_SYNC}.
*/
@ConfigItem(defaultValue = "quarkus.sessions")
public String cacheName;

/**
* Maximum time to retry when retrieving session data from the Infinispan cache.
* The Vert.x session handler retries when the session data are not found, because
* distributing data across an Infinispan cluster may take time.
*/
@ConfigItem(defaultValue = "5s")
public Duration retryTimeout;
}
Loading

0 comments on commit 45480f2

Please sign in to comment.