You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/04/08 02:06:05 UTC
[GitHub] [pulsar] jiazhai commented on a change in pull request #6684:
Support function with format: Function>
jiazhai 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_r405216485
##########
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:
Ok. Thanks for the suggestion.
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services