Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArC and Vert.x: introduce InvokerFactoryBuildItem and use it in Vert.x event bus consumers #40815

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,11 @@
<artifactId>quarkus-vertx-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-latebound-mdc-provider</artifactId>
Expand Down Expand Up @@ -1952,6 +1957,16 @@
<artifactId>quarkus-vertx-http-dev-ui-resources</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin-deployment</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
Expand Down
13 changes: 13 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin</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-virtual-threads</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2955,6 +2955,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin-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-virtual-threads-deployment</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions docs/src/main/asciidoc/kotlin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,12 @@
|`quarkus-smallrye-fault-tolerance`
|Support is provided for the declarative annotation-based API

|`quarkus-vertx`
|Support is provided for `@ConsumeEvent` methods

Check warning on line 505 in docs/src/main/asciidoc/kotlin.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'coroutines'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'coroutines'?", "location": {"path": "docs/src/main/asciidoc/kotlin.adoc", "range": {"start": {"line": 505, "column": 9}}}, "severity": "WARNING"}

|===

=== Kotlin coroutines and Mutiny

Check warning on line 509 in docs/src/main/asciidoc/kotlin.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Kotlin coroutines and Mutiny'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Kotlin coroutines and Mutiny'.", "location": {"path": "docs/src/main/asciidoc/kotlin.adoc", "range": {"start": {"line": 509, "column": 5}}}, "severity": "INFO"}

Check warning on line 509 in docs/src/main/asciidoc/kotlin.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'coroutines'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'coroutines'?", "location": {"path": "docs/src/main/asciidoc/kotlin.adoc", "range": {"start": {"line": 509, "column": 12}}}, "severity": "WARNING"}

Kotlin coroutines provide an imperative programming model that actually gets executed in an asynchronous, reactive manner.
To simplify the interoperability between Mutiny and Kotlin there is the module `io.smallrye.reactive:mutiny-kotlin`, described link:https://smallrye.io/smallrye-mutiny/latest/guides/kotlin/[here].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ public BeanRegistrationPhaseBuildItem registerBeans(ContextRegistrationPhaseBuil
List<ContextConfiguratorBuildItem> contextConfigurationRegistry,
BuildProducer<InterceptorResolverBuildItem> interceptorResolver,
BuildProducer<BeanDiscoveryFinishedBuildItem> beanDiscoveryFinished,
BuildProducer<TransformedAnnotationsBuildItem> transformedAnnotations) {
BuildProducer<TransformedAnnotationsBuildItem> transformedAnnotations,
BuildProducer<InvokerFactoryBuildItem> invokerFactory) {

for (ContextConfiguratorBuildItem contextConfigurator : contextConfigurationRegistry) {
for (ContextConfigurator value : contextConfigurator.getValues()) {
Expand All @@ -440,6 +441,7 @@ public BeanRegistrationPhaseBuildItem registerBeans(ContextRegistrationPhaseBuil
interceptorResolver.produce(new InterceptorResolverBuildItem(beanDeployment));
beanDiscoveryFinished.produce(new BeanDiscoveryFinishedBuildItem(beanDeployment));
transformedAnnotations.produce(new TransformedAnnotationsBuildItem(beanDeployment));
invokerFactory.produce(new InvokerFactoryBuildItem(beanDeployment));

return new BeanRegistrationPhaseBuildItem(registrationContext, beanProcessor);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.arc.deployment;

import org.jboss.jandex.MethodInfo;

import io.quarkus.arc.processor.BeanDeployment;
import io.quarkus.arc.processor.BeanInfo;
import io.quarkus.arc.processor.InvokerBuilder;
import io.quarkus.arc.processor.InvokerFactory;
import io.quarkus.builder.item.SimpleBuildItem;

/**
* Provides access to {@link InvokerFactory}. May only be used in the bean registration phase,
* observer registration phase, and validation phase (basically, until ArC generates
* the classes). Afterwards, any attempt to call {@link #createInvoker(BeanInfo, MethodInfo)}
* throws an exception.
*/
public final class InvokerFactoryBuildItem extends SimpleBuildItem {
private final BeanDeployment beanDeployment;

public InvokerFactoryBuildItem(BeanDeployment beanDeployment) {
this.beanDeployment = beanDeployment;
}

public InvokerBuilder createInvoker(BeanInfo bean, MethodInfo method) {
// always call `BeanDeployment.getInvokerFactory()`, because that checks whether it's too late
return beanDeployment.getInvokerFactory().createInvoker(bean, method);
}
}
5 changes: 5 additions & 0 deletions extensions/kotlin/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<artifactId>kotlin-compiler</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin-deployment</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
6 changes: 6 additions & 0 deletions extensions/kotlin/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,11 @@
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-jdk8</artifactId>
</dependency>

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

<artifactId>quarkus-vertx-deployment-spi</artifactId>
<name>Quarkus - Vert.x - Deployment - SPI</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus.arc</groupId>
<artifactId>arc-processor</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.vertx.deployment.spi;

import java.util.function.BiConsumer;

import org.jboss.jandex.MethodInfo;

import io.quarkus.arc.processor.InvokerBuilder;
import io.quarkus.builder.item.MultiBuildItem;

/**
* This build item should be considered private and should not be used outside of core Quarkus.
* It can be changed without notice.
*/
public final class EventConsumerInvokerCustomizerBuildItem extends MultiBuildItem {
private final BiConsumer<MethodInfo, InvokerBuilder> invokerCustomizer;

public EventConsumerInvokerCustomizerBuildItem(BiConsumer<MethodInfo, InvokerBuilder> invokerCustomizer) {
this.invokerCustomizer = invokerCustomizer;
}

public BiConsumer<MethodInfo, InvokerBuilder> getInvokerCustomizer() {
return invokerCustomizer;
}
}
4 changes: 4 additions & 0 deletions extensions/vertx/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
Expand Down
Loading
Loading