You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Java implementation for proxy-wasm, enabling developer to run Proxy-Wasm plugins in Java.
9
+
The Quarkus implementation for proxy-wasm, enabling developer to run Proxy-Wasm plugins in Java.
9
10
10
11
## Overview
11
12
@@ -39,15 +40,13 @@ public class Example {
39
40
}
40
41
```
41
42
42
-
And then using the [`Plugin builder`](https://javadoc.io/doc/io.roastedroot/proxy-wasm-java-host/latest/io/roastedroot/proxywasm/Plugin.Builder.html) API to configure the Proxy-Wasm plugin that has a matching name:
43
+
And then using the [`PluginFactory builder`](https://javadoc.io/doc/io.roastedroot/proxy-wasm-java-host/latest/io/roastedroot/proxywasm/PluginFactory.Builder.html) API to configure the Proxy-Wasm plugin that has a matching name:
.withPluginConfig(" ... the config passed to the plugin ... ")
68
66
.withMetricsHandler(newSimpleMetricsHandler())
@@ -71,21 +69,94 @@ public class App {
71
69
}
72
70
```
73
71
74
-
### Compiling WASM to Bytecode (Experimental)
72
+
### Compiling WASM to Bytecode
75
73
76
-
By default, wsm modules are executed using the [Chicory](https://chicory.dev/) interpreter. But if you want the wasm to
74
+
By default, WASM modules are executed using the [Chicory](https://chicory.dev/) interpreter. But if you want the WASM code to
77
75
run a near native speed, you should compile the WASM to Java bytecode using the chicory WASM to bytecode compiler.
78
-
Chicory supports compiling the WASM module at either build time or runtime. If you want to compile your Quarkus app to
79
-
native, then you MUST compile the WASM module at build (time to avoid the use of runtime reflection). Please refer
80
-
to the [Chicory documentation](https://chicory.dev/docs/) for more details on how to compile the WASM module to Java
81
-
bytecode. Compiling will produce a machine factory that you should pass as an argument to the [withMachineFactory](https://javadoc.io/doc/io.roastedroot/proxy-wasm-java-host/latest/io/roastedroot/proxywasm/Plugin.Builder.html#withMachineFactory(java.util.function.Function))
82
-
method to enable the bytecode execution of the WASM module.
76
+
Chicory supports compiling the WASM module at either build time or runtime.
77
+
78
+
#### Runtime Compilation
79
+
80
+
To enable runtime compilation, you need just need to add the following dependency to your `pom.xml`:
81
+
82
+
```xml
83
+
<dependency>
84
+
<groupId>com.dylibso.chicory</groupId>
85
+
<artifactId>compiler</artifactId>
86
+
</dependency>
87
+
```
88
+
89
+
You then enable it on the PluginFactory builder by using it as the machine factory:
By default, WASM modules are executed using the link:https://chicory.dev/[Chicory] interpreter. But if you want the WASM to
181
-
run a near native speed, you should compile the WASM to Java bytecode using the chicory WASM to bytecode compiler.
182
-
Chicory supports compiling the WASM module at either build time or runtime. If you want to compile your Quarkus app to
183
-
native, then you MUST compile the WASM module at build (time to avoid the use of runtime reflection). Please refer
184
-
to the link:https://chicory.dev/docs/[Chicory documentation] for more details on how to compile the WASM module to Java
185
-
bytecode. Compiling will produce a machine factory that you should pass as an argument to the link:https://javadoc.io/doc/io.roastedroot/proxy-wasm-java-host/latest/io/roastedroot/proxywasm/Plugin.Builder.html#withMachineFactory(java.util.function.Function)[withMachineFactory]
186
-
method to enable the bytecode execution of the WASM module.
179
+
By default, WASM modules are executed using the https://chicory.dev/[Chicory] interpreter.
180
+
But if you want the WASM code to run at near native speed, you should compile the WASM to Java bytecode using the Chicory WASM to bytecode compiler.
181
+
Chicory supports compiling the WASM module at either build time or runtime.
182
+
183
+
==== Runtime Compilation
184
+
185
+
To enable runtime compilation, you just need to add the following dependency to your `pom.xml`:
186
+
187
+
[source,xml]
188
+
----
189
+
<dependency>
190
+
<groupId>com.dylibso.chicory</groupId>
191
+
<artifactId>compiler</artifactId>
192
+
</dependency>
193
+
----
194
+
195
+
You then enable it on the PluginFactory builder by using it as the machine factory:
This will generate a `WasmShim` class that provides both a `load()` method to get the `WasmModule` and a `create()` method for the machine factory. Update your plugin factory to use the compiled module:
239
+
240
+
[source,java]
241
+
----
242
+
@Produces
243
+
public PluginFactory waf() {
244
+
return PluginFactory.builder(WasmShim.load())
245
+
.withMachineFactory(WasmShim::create)
246
+
.withName("waf")
247
+
.withPluginConfig(CONFIG)
248
+
.withMetricsHandler(new SimpleMetricsHandler())
249
+
.build();
250
+
}
251
+
----
252
+
253
+
Please refer to the https://chicory.dev/docs/usage/build-time-compiler[Chicory Build time Compilation documentation] for more details.
0 commit comments