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

Add Wasm extension #6012

Merged
merged 1 commit into from
Apr 19, 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
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/components/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-wasm
cqArtifactIdBase: wasm
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 3.10.0
cqNativeSince: 3.10.0
cqCamelPartName: wasm
cqCamelPartTitle: Wasm
cqCamelPartDescription: Invoke Wasm functions.
cqExtensionPageTitle: Wasm
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/languages/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-wasm
cqArtifactIdBase: wasm
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 3.10.0
cqNativeSince: 3.10.0
cqCamelPartName: wasm
cqCamelPartTitle: Wasm
cqCamelPartDescription: Call a wasm (web assembly) function.
cqExtensionPageTitle: Wasm
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
*** xref:reference/extensions/vertx.adoc[Vert.x]
*** xref:reference/extensions/vertx-http.adoc[Vert.x HTTP Client]
*** xref:reference/extensions/vertx-websocket.adoc[Vert.x WebSocket]
*** xref:reference/extensions/wasm.adoc[Wasm]
*** xref:reference/extensions/weather.adoc[Weather]
*** xref:reference/extensions/web3j.adoc[Web3j Ethereum Blockchain]
*** xref:reference/extensions/wordpress.adoc[Wordpress]
Expand Down
64 changes: 64 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/wasm.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-wasm"]
= Wasm
:linkattrs:
:cq-artifact-id: camel-quarkus-wasm
:cq-native-supported: true
:cq-status: Experimental
:cq-status-deprecation: Experimental
:cq-description: Invoke Wasm functions.
:cq-deprecated: false
:cq-jvm-since: 3.10.0
:cq-native-since: 3.10.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##3.10.0## [.badge-key]##Native since##[.badge-supported]##3.10.0##
endif::[]

Invoke Wasm functions.

[id="extensions-wasm-whats-inside"]
== What's inside

* xref:{cq-camel-components}::wasm-component.adoc[Wasm component], URI syntax: `wasm:functionName`
* xref:{cq-camel-components}:languages:wasm-language.adoc[Wasm language]

Please refer to the above links for usage and configuration details.

[id="extensions-wasm-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-wasm[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-wasm</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-wasm-usage"]
== Usage
[id="extensions-wasm-usage-reading-wasm-modules-from-the-classpath-in-native-mode"]
== Reading Wasm modules from the classpath in native mode

When Wasm modules are read from the classpath (the default) in native mode, you must ensure that the module(s) are added to the native image.
You can do this via a configuration property in `application.properties`.

For example, assuming `.wasm` files are read from a classpath location of `was/modules`.

[source,properties]
----
quarkus.native.resources.includes = wasm/modules/*.wasm
----

More information about selecting resources for inclusion in the native executable can be found in the xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[native mode user guide].

1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<module>vertx</module>
<module>vertx-http</module>
<module>vertx-websocket</module>
<module>wasm</module>
<module>weather</module>
<module>xchange</module>
<module>xj</module>
Expand Down
67 changes: 67 additions & 0 deletions extensions/wasm/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<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>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-wasm-parent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-wasm-deployment</artifactId>
<name>Camel Quarkus :: Wasm :: Deployment</name>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-wasm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson-deployment</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.wasm.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import org.apache.camel.wasm.WasmSupport.Wrapper;

class WasmProcessor {

private static final String FEATURE = "camel-wasm";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
ReflectiveClassBuildItem registerForReflection() {
return ReflectiveClassBuildItem.builder(Wrapper.class).methods(false).fields(true).build();
}
}
39 changes: 39 additions & 0 deletions extensions/wasm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<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>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-extensions</artifactId>
<version>3.10.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-wasm-parent</artifactId>
<name>Camel Quarkus :: Wasm</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
</project>
106 changes: 106 additions & 0 deletions extensions/wasm/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<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>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-wasm-parent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-wasm</artifactId>
<name>Camel Quarkus :: Wasm :: Runtime</name>
<description>Invoke Wasm functions.</description>

<properties>
<camel.quarkus.jvmSince>3.10.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>3.10.0</camel.quarkus.nativeSince>
<quarkus.metadata.status>experimental</quarkus.metadata.status>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-wasm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>


<profiles>
<profile>
<id>full</id>
<activation>
<property>
<name>!quickly</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-maven-plugin</artifactId>
<executions>
<execution>
<id>update-extension-doc-page</id>
<goals>
<goal>update-extension-doc-page</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
13 changes: 13 additions & 0 deletions extensions/wasm/runtime/src/main/doc/usage.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
== Reading Wasm modules from the classpath in native mode

When Wasm modules are read from the classpath (the default) in native mode, you must ensure that the module(s) are added to the native image.
You can do this via a configuration property in `application.properties`.

For example, assuming `.wasm` files are read from a classpath location of `was/modules`.

[source,properties]
----
quarkus.native.resources.includes = wasm/modules/*.wasm
----

More information about selecting resources for inclusion in the native executable can be found in the xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[native mode user guide].
Loading
Loading