Class CallDurableFuture<T>
java.lang.Object
dev.restate.sdk.CallDurableFuture<T>
- All Implemented Interfaces:
DurableFuture<T>
DurableFuture returned by a call to another service.
You can retrieve the call invocation id using invocationId(), and you can cancel the
invocation using cancel().
-
Method Summary
Modifier and TypeMethodDescriptionfinal Tawait()Wait for thisDurableFutureto complete.final TSame asDurableFuture.await(), but throws aTimeoutExceptionif thisDurableFuturedoesn't complete before the providedtimeout.voidcancel()Cancel this invocationfinal <U> DurableFuture<U> map(ThrowingFunction<T, U> mapper) Map the success result of thisDurableFuture.final <U> DurableFuture<U> map(ThrowingFunction<T, U> successMapper, ThrowingFunction<TerminalException, U> failureMapper) Map both the success and the failure result of thisDurableFuture.final DurableFuture<T> mapFailure(ThrowingFunction<TerminalException, T> failureMapper) Map the failure result of thisDurableFuture.final DurableFuture<T> withTimeout(Duration timeout)
-
Method Details
-
invocationId
- Returns:
- the invocation id of this call.
-
cancel
public void cancel()Cancel this invocation -
await
Description copied from interface:DurableFutureWait for thisDurableFutureto complete.Executing this method may trigger the suspension of the function.
NOTE: You should never wrap this function in a try-catch catching
Throwable, as it will catchAbortedExecutionExceptionas well, which will prevent the service invocation to orderly suspend.- Specified by:
awaitin interfaceDurableFuture<T>- Throws:
TerminalException- if this future was completed with a failure
-
await
Description copied from interface:DurableFutureSame asDurableFuture.await(), but throws aTimeoutExceptionif thisDurableFuturedoesn't complete before the providedtimeout.- Specified by:
awaitin interfaceDurableFuture<T>- Throws:
TerminalException
-
withTimeout
- Specified by:
withTimeoutin interfaceDurableFuture<T>- Returns:
- a
DurableFuturethat throws aTimeoutExceptionif this future doesn't complete before the providedtimeout.
-
map
Description copied from interface:DurableFutureMap the success result of thisDurableFuture.- Specified by:
mapin interfaceDurableFuture<T>- Parameters:
mapper- the mapper to execute if thisDurableFuturecompletes with success. The mapper can throw aTerminalException, thus failing the resultingDurableFuture.- Returns:
- a new
DurableFuturewith the mapped result, when completed
-
map
public final <U> DurableFuture<U> map(ThrowingFunction<T, U> successMapper, ThrowingFunction<TerminalException, U> failureMapper) Description copied from interface:DurableFutureMap both the success and the failure result of thisDurableFuture.- Specified by:
mapin interfaceDurableFuture<T>- Parameters:
successMapper- the mapper to execute if thisDurableFuturecompletes with success. The mapper can throw aTerminalException, thus failing the resultingDurableFuture.failureMapper- the mapper to execute if thisDurableFuturecompletes with failure. The mapper can throw aTerminalException, thus failing the resultingDurableFuture.- Returns:
- a new
DurableFuturewith the mapped result, when completed
-
mapFailure
Description copied from interface:DurableFutureMap the failure result of thisDurableFuture.- Specified by:
mapFailurein interfaceDurableFuture<T>- Parameters:
failureMapper- the mapper to execute if thisDurableFuturecompletes with failure. The mapper can throw aTerminalException, thus failing the resultingDurableFuture.- Returns:
- a new
DurableFuturewith the mapped result, when completed
-