Class AsyncMethodCallbacks
java.lang.Object
com.linecorp.armeria.common.thrift.AsyncMethodCallbacks
A utility class that bridges the gap between
CompletionStage
and AsyncMethodCallback
.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
invokeOnError
(org.apache.thrift.async.AsyncMethodCallback<?> callback, Throwable cause) InvokesAsyncMethodCallback.onError(Exception)
.static <T> void
transfer
(CompletionStage<T> src, org.apache.thrift.async.AsyncMethodCallback<? super T> dest) Adds a callback that transfers the outcome of the specifiedCompletionStage
to the specifiedAsyncMethodCallback
.
-
Method Details
-
transfer
public static <T> void transfer(CompletionStage<T> src, org.apache.thrift.async.AsyncMethodCallback<? super T> dest) Adds a callback that transfers the outcome of the specifiedCompletionStage
to the specifiedAsyncMethodCallback
.> public class MyThriftService implements ThriftService.AsyncIface { > @Override > public void myServiceMethod(AsyncMethodCallback<MyResult> callback) { > final CompletableFuture<MyResult> future = ...; > AsyncMethodCallbacks.transfer(future, callback); > } > }
-
invokeOnError
public static void invokeOnError(org.apache.thrift.async.AsyncMethodCallback<?> callback, Throwable cause) InvokesAsyncMethodCallback.onError(Exception)
. If the specifiedcause
is not anException
, it will be wrapped with aCompletionException
.
-