public class AsyncTimeout<V> extends Object implements FaultToleranceStrategy<Future<V>>
Timeout, and it is invoked on an extra thread.
Communication then happens using TimeoutEvent.
Note that the TimeoutException thrown from this strategy might come from two places:
the Timeout strategy throwing, or AsyncTimeoutTask#timedOut setting an exception
as a result of TimeoutEvent. Both might happen, and whichever happens first gets to decide.
That's why we take extra care to make sure that there's only one place where the exception is created.
| Constructor and Description |
|---|
AsyncTimeout(FaultToleranceStrategy<Future<V>> delegate,
Executor executor) |
| Modifier and Type | Method and Description |
|---|---|
Future<V> |
apply(InvocationContext<Future<V>> ctx)
Apply the fault tolerance strategy around the target
Callable. |
public AsyncTimeout(FaultToleranceStrategy<Future<V>> delegate, Executor executor)
public Future<V> apply(InvocationContext<Future<V>> ctx) throws Exception
FaultToleranceStrategyCallable.
The Callable is wrapped in an InvocationContext.apply in interface FaultToleranceStrategy<Future<V>>ctx - the InvocationContext wrapping the Callable guarded by this fault tolerance strategyCallableException - if result couldn't be computedCopyright © 2018–2020. All rights reserved.