public final class TimeoutMethodUtils extends Object
AbstractToolingRequest operation and abort if the configuration timeout
is reached before the operation is completed.| Constructor and Description |
|---|
TimeoutMethodUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
withTimeout(long timeout,
Supplier<T> resultSupplier,
Optional<Function<Throwable,T>> throwableTFunction,
Optional<Consumer<TimeoutException>> cleanupFunctionOnTimeout)
Evalues the resultSupplier provided for the given timeout defined for the request, if the operation
is not completed before timeout is reached a
TimeoutException is thrown. |
public static <T> T withTimeout(long timeout,
Supplier<T> resultSupplier,
Optional<Function<Throwable,T>> throwableTFunction,
Optional<Consumer<TimeoutException>> cleanupFunctionOnTimeout)
TimeoutException is thrown. In case of errors during the operation
a function is provided for handling them properly.T - the type of the operation result.timeout - the request operation timeout in milliseconds. -1 means no timeout block until it gets the response.resultSupplier - the function that evaluates the operation and returns the result. Not null.throwableTFunction - in case if the operation throws an exception an optional function to handle it can be passed.cleanupFunctionOnTimeout - in case if the operation is timed out an optional function to clean up resources is executed.Copyright © 2017 MuleSoft, Inc.. All rights reserved.