sijie commented on a change in pull request #6684: Support function with
format: Function<I, CompletableFuture<O>>
URL: https://github.com/apache/pulsar/pull/6684#discussion_r404987985
##########
File path:
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstance.java
##########
@@ -52,23 +53,49 @@ public JavaInstance(ContextImpl contextImpl, Object
userClassObject) {
}
}
- public JavaExecutionResult handleMessage(Record<?> record, Object input) {
+ public CompletableFuture<JavaExecutionResult> handleMessage(Record<?>
record, Object input) {
if (context != null) {
context.setCurrentMessageContext(record);
}
+
+ final CompletableFuture<JavaExecutionResult> future = new
CompletableFuture<>();
JavaExecutionResult executionResult = new JavaExecutionResult();
+
try {
Object output;
if (function != null) {
output = function.process(input, context);
} else {
output = javaUtilFunction.apply(input);
}
- executionResult.setResult(output);
+
+ if (output instanceof CompletableFuture) {
+ // Function is in format: Function<I, CompletableFuture<O>>
+ ((CompletableFuture) output).whenComplete((obj, throwable) -> {
Review comment:
shared the same concern here. I think we need to introduce a setting to
limit the max outstanding items (results) being processed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services