use of scala.concurrent.impl.Promise in project flink by apache.
the class AkkaRpcActor method sendAsyncResponse.
private void sendAsyncResponse(CompletableFuture<?> asyncResponse, String methodName) {
final ActorRef sender = getSender();
Promise.DefaultPromise<Object> promise = new Promise.DefaultPromise<>();
FutureUtils.assertNoException(asyncResponse.handle((value, throwable) -> {
if (throwable != null) {
promise.failure(throwable);
} else {
if (isRemoteSender(sender)) {
Either<AkkaRpcSerializedValue, AkkaRpcException> serializedResult = serializeRemoteResultAndVerifySize(value, methodName);
if (serializedResult.isLeft()) {
promise.success(serializedResult.left());
} else {
promise.failure(serializedResult.right());
}
} else {
promise.success(new Status.Success(value));
}
}
// consume the provided throwable
return null;
}));
Patterns.pipe(promise.future(), getContext().dispatcher()).to(sender);
}
Aggregations