Class FutureRpcResults
java.lang.Object
org.opendaylight.serviceutils.tools.rpc.FutureRpcResults
Utility to simplify correctly handling transformation of Future of RpcResult to return.
- Author:
- Michael Vorburger.ch
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static enum
-
Method Summary
Modifier and TypeMethodDescriptionstatic <I,
O> FutureRpcResults.FutureRpcResultBuilder <I, O> fromBuilder
(org.slf4j.Logger logger, String rpcMethodName, @Nullable I input, Callable<O> callable) static <I,
O> FutureRpcResults.FutureRpcResultBuilder <I, O> fromListenableFuture
(org.slf4j.Logger logger, String rpcMethodName, @Nullable I input, Callable<com.google.common.util.concurrent.ListenableFuture<O>> callable) Create a Builder for a ListenableFuture to Future<RpcResult<O>> transformer.
-
Method Details
-
fromListenableFuture
@CheckReturnValue public static <I,O> FutureRpcResults.FutureRpcResultBuilder<I,O> fromListenableFuture(org.slf4j.Logger logger, String rpcMethodName, @Nullable I input, Callable<com.google.common.util.concurrent.ListenableFuture<O>> callable) Create a Builder for a ListenableFuture to Future<RpcResult<O>> transformer. By default, the future will log success or failure, with configurable log levels; the caller can also add handlers for success and/or failure.- Parameters:
logger
- the slf4j Logger of the callerrpcMethodName
- Java method name (without "()") of the RPC operation, used for logginginput
- the RPC input DataObject of the caller (may be null)callable
- the Callable (typically lambda) creating a ListenableFuture. Note that the functional interface Callable's call() method declares throws Exception, so your lambda does not have to do any exception handling (specifically it does NOT have to catch and wrap any exception into a failed Future); this utility does that for you.- Returns:
- a new FutureRpcResultBuilder
-
fromBuilder
@CheckReturnValue public static <I,O> FutureRpcResults.FutureRpcResultBuilder<I,O> fromBuilder(org.slf4j.Logger logger, String rpcMethodName, @Nullable I input, Callable<O> callable)
-