Class AsyncMethodCallbacks

java.lang.Object
com.linecorp.armeria.common.thrift.AsyncMethodCallbacks

public final class AsyncMethodCallbacks extends Object
A utility class that bridges the gap between CompletionStage and AsyncMethodCallback.
  • 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 specified CompletionStage to the specified AsyncMethodCallback.
      
       > 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)
      Invokes AsyncMethodCallback.onError(Exception). If the specified cause is not an Exception, it will be wrapped with a CompletionException.