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


##########
components/camel-wasm/src/main/docs/wasm-language.adoc:
##########
@@ -170,6 +170,24 @@ YAML::
 ====
 
 
+== Using Wasm as a predicate
+
+When the function is used as a xref:manual::predicate.adoc[Predicate], for 
example with the
+xref:eips:filter-eip.adoc[Filter] EIP, its result is converted to a boolean 
with the standard Camel rules:
+a `Boolean` is used directly, the strings `true` and `false` (in any case) are 
parsed, empty data is
+`false`, and any other non-null value is `true`. With the default result type 
(`byte[]`), the returned
+bytes are first converted to a string, so the function can simply return 
`true` or `false`.
+If the result type is a Jackson `JsonNode`, only the JSON boolean `true` 
matches.
+
+[source,java]
+----
+from("direct:in")
+    .filter()
+        .wasm("is_valid", "classpath://functions.wasm")
+    .to("direct:valid");
+----

Review Comment:
   Language pages now show their examples as Java/XML/YAML tabs (CAMEL-25265), 
including the `transform` example above on this page, and doc examples are 
checked in the build. Could this one be tabbed too, with the canonical YAML 
form? Also, `.to(...)` sits inside the filter, so indenting it under 
`.filter()` reads more clearly. Please mirror the change in 
`catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/wasm-language.adoc`.
   ```suggestion
   [tabs]
   ====
   Java::
   +
   [source,java]
   ----
   from("direct:in")
       .filter().wasm("is_valid", "classpath://functions.wasm")
           .to("direct:valid");
   ----
   
   XML::
   +
   [source,xml]
   ----
   <route>
     <from uri="direct:in"/>
     <filter>
       <wasm module="classpath://functions.wasm">is_valid</wasm>
       <to uri="direct:valid"/>
     </filter>
   </route>
   ----
   
   YAML::
   +
   [source,yaml]
   ----
   - route:
       from:
         uri: direct:in
         steps:
           - filter:
               expression:
                 wasm:
                   expression: is_valid
                   module: classpath://functions.wasm
               steps:
                 - to:
                     uri: direct:valid
   ----
   ====
   ```



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc:
##########
@@ -2891,6 +2891,13 @@ example:
 This is not a functional change for messages without a `DOCTYPE`, and it does 
not add a document parse:
 `XPathExpression.evaluate(InputSource)` already built a full DOM internally.
 
+=== camel-wasm - the wasm predicate

Review Comment:
   Heads-up: #27593 adds another camel-wasm note (`=== camel-wasm - a failed 
call discards the Wasm instance`) between camel-tika and camel-xpath. They 
merge cleanly, but would end up separated by the camel-xpath section. Whichever 
merges second, please keep the two camel-wasm notes together, or under one `=== 
camel-wasm` heading.



-- 
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