davsclaus commented on code in PR #27793:
URL: https://github.com/apache/camel/pull/27793#discussion_r4266921943


##########
components/camel-wasm/src/main/java/org/apache/camel/component/wasm/WasmEndpoint.java:
##########
@@ -63,6 +75,44 @@ public WasmConfiguration getConfiguration() {
         return configuration;
     }
 
+    /**
+     * The module of this endpoint as a command. The module is loaded, checked 
and, with compile=true, compiled on the
+     * first call, by the first producer that is initialized; all producers of 
the endpoint then share the result, which
+     * is immutable, for as long as the endpoint exists. So a route that is 
stopped and started again gets a new
+     * producer, but neither loads nor compiles the module again, and the 
classes generated for a compiled module can
+     * only be unloaded when the endpoint is no longer reachable (removed from 
the context, or the context stopped), not
+     * when a route stops.
+     * <p/>
+     * A failed call leaves nothing behind, so the next call (of the next 
producer that is initialized) tries again.
+     */
+    WasiCommand command() throws Exception {
+        WasiCommand answer = command;
+        if (answer == null) {
+            lock.lock();
+            try {
+                answer = command;
+                if (answer == null) {
+                    List<String> arguments
+                            = 
WasmProducer.arguments(WasmProducer.programName(module), 
configuration.getArgs());

Review Comment:
   Nit: the endpoint now calls `WasmProducer.arguments`, 
`WasmProducer.programName` and `WasmProducer.checkNoNul` (which lost its 
`private` for this). The module is loaded and checked by the endpoint now, so 
these helpers belong next to `command()`. Consider moving them to 
`WasmEndpoint` (or a small package-private helper). `WasmProducer` can call 
them from there for the environment checks.



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -111,6 +111,12 @@ module.
 * `WasmSupport.deserialize(byte[], Exchange)`.
 * The constructor `WasmProducer(Endpoint, String, String)` is replaced by 
`WasmProducer(WasmEndpoint)`.
 
+The endpoint has a new `compile` option (default `false`) that runs a module 
as JVM bytecode instead of interpreting
+it. For this option `camel-wasm` has a new dependency, `run.endive:compiler`, 
which brings in ASM (`org.ow2.asm`).
+The module is now loaded once per endpoint and no longer by every producer, so 
stopping and starting a route does
+not read the module again: remove the route and add it again, or restart the 
application, to load a module that
+has changed.

Review Comment:
   Suggestion: lead with what changes for an upgrading user (the new dependency 
and the loading change). CLAUDE.md keeps the upgrade guide to migration notes, 
not features.
   
   ```suggestion
   `camel-wasm` has a new dependency, `run.endive:compiler`, which brings in 
ASM (`org.ow2.asm`). It is used by the
   new `compile` option of the endpoint (default `false`). The module is now 
loaded once per endpoint and no longer by
   every producer, so stopping and starting a route does not read the module 
again: remove the route and add it
   again, or restart the application, to load a module that has changed.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to