Package org.consensusj.jsonrpc
Interface AsyncSupport
- All Known Subinterfaces:
JsonRpcClient<T>
,JsonRpcTransport<T>
,PollingChainTipService
,RxJsonChainTipClient
,RxJsonRpcClient
- All Known Implementing Classes:
BitcoinClient
,BitcoinExtendedClient
,DefaultRpcClient
,EthereumClient
,JsonRpcClientHttpUrlConnection
,JsonRpcClientJavaNet
,NamecoinClient
,PollingChainTipServiceImpl
,RxBitcoinClient
public interface AsyncSupport
Helper methods for creating asynchronous calls using
CompletableFuture
. Since the
synchronous methods in DefaultRpcClient
throw checked exceptions this interface
provides wrapper support to make it easier to convert them to async calls.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Subinterface ofSupplier
for Lambdas which throwIOException
.static interface
Error filter for resilient polling. -
Method Summary
Modifier and TypeMethodDescriptiondefault Executor
Return the default executor for supplying asynchronicity.default <T> CompletableFuture
<T> supplyAsync
(AsyncSupport.ThrowingSupplier<T> throwingSupplier) Supply async for a ThrowingSupplier by catching exceptions and completing exceptionally.default <T> CompletableFuture
<T> supplyAsync
(AsyncSupport.ThrowingSupplier<T> throwingSupplier, Executor executor) Supply async for a ThrowingSupplier by catching exceptions and completing exceptionally.
-
Method Details
-
supplyAsync
Supply async for a ThrowingSupplier by catching exceptions and completing exceptionally.- Type Parameters:
T
- return type- Parameters:
throwingSupplier
- Supplier of T that can throw anIOException
- Returns:
- A completable future, returning T
-
supplyAsync
default <T> CompletableFuture<T> supplyAsync(AsyncSupport.ThrowingSupplier<T> throwingSupplier, Executor executor) Supply async for a ThrowingSupplier by catching exceptions and completing exceptionally.- Type Parameters:
T
- return type- Parameters:
throwingSupplier
- Supplier of T that can throw anIOException
executor
- Executor to run the Supplier- Returns:
- A completable future, returning T
-
getDefaultAsyncExecutor
Return the default executor for supplying asynchronicity.- Returns:
- An executor.
-