tzulitai commented on a change in pull request #177:
URL: https://github.com/apache/flink-statefun/pull/177#discussion_r529225249
##########
File path:
statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/reqreply/RequestReplyFunction.java
##########
@@ -125,8 +126,44 @@ private void onAsyncResult(
sendToFunction(context, batch);
return;
}
- InvocationResponse invocationResult =
unpackInvocationOrThrow(context.self(), asyncResult);
- handleInvocationResponse(context, invocationResult);
+ if (asyncResult.failure()) {
+ throw new IllegalStateException(
+ "Failure forwarding a message to a remote function " +
context.self(),
+ asyncResult.throwable());
+ }
+
+ final Either<InvocationResponse, IncompleteInvocationContext> response =
+ unpackResponse(asyncResult.value());
+ if (response.isRight()) {
+ handleIncompleteInvocationContextResponse(context, response.right(),
asyncResult.metadata());
+ } else {
+ handleInvocationResultResponse(context, response.left());
+ }
+ }
+
+ private static Either<InvocationResponse, IncompleteInvocationContext>
unpackResponse(
Review comment:
But I guess it won't hurt to make this explicit in the code as you
suggested, so that the behaviour is clear:
```
if (fromFunction.hasIncompleteInvocationContext()) {
return Either.Right(fromFunction.getIncompleteInvocationContext());
}
if (fromFunction.hasInvocationResult()) {
return Either.Left(fromFunction.getInvocationResult());
}
// function had no side effects
return Either.Left(InvocationResult.getDefaultInstance());
```
does this look good to you?
----------------------------------------------------------------
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]