Interface HandlerContext
public interface HandlerContext
Internal interface to access Restate functionalities. Users can use the ad-hoc RestateContext
interfaces provided by the various implementations.
The operations producing a result return a HandlerContext.Handle to it. To get the result, build a
future tree out of the handles (HandlerContext.UnresolvedFuture) and await(UnresolvedFuture)
it.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceResult ofawait(UnresolvedFuture).static final recordstatic final recordstatic interfaceOpaque handle to the result of an operation, returned by theHandlerContextoperations, and used to build theHandlerContext.UnresolvedFuture.Singlenodes of a future tree.static interfaceResult of an operation.static interfacestatic interfaceNode of a future tree, awaited withawait(UnresolvedFuture). -
Method Summary
Modifier and TypeMethodDescriptionattachInvocation(String invocationId) Restate-protocol-level HTTP headers received on the current invocation attempt.Await the given future tree, until either one of its singles completes, or the invocation is cancelled or aborted.call(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers) call(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable Collection<Map.Entry<String, String>> headers) Deprecated.cancelInvocation(String invocationId) booleanbooleanbooleanbooleanclearAll()voidgetInvocationOutput(String invocationId) getKeys()default PayloadCodecpeekPromise(String key) rejectAwakeable(String id, TerminalException reason) rejectPromise(String key, TerminalException reason) rejectSignal(String invocationId, String name, TerminalException reason) request()resolveAwakeable(String id, Slice payload) resolvePromise(String key, Slice payload) resolveSignal(String invocationId, String name, Slice payload) send(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers, @Nullable Duration delay) default CompletableFuture<HandlerContext.Handle<String>> send(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable Collection<Map.Entry<String, String>> headers, @Nullable Duration delay) Deprecated.submitRun(@Nullable String name, Consumer<HandlerContext.RunCompleter> closure) writeOutput(Slice value) Deprecated, for removal: This API element is subject to removal in a future version.writeOutput(TerminalException exception) Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Details
-
objectKey
String objectKey() -
request
HandlerRequest request() -
attemptHeaders
HeadersAccessor attemptHeaders()Restate-protocol-level HTTP headers received on the current invocation attempt. Differs across retries. -
payloadCodec
- Returns:
- the codec to apply to the payloads, after serializing them and before deserializing them. Payloads passed to and returned by this interface are always encoded.
-
canReadState
boolean canReadState() -
canWriteState
boolean canWriteState() -
canReadPromises
boolean canReadPromises() -
canWritePromises
boolean canWritePromises() -
writeOutput
Deprecated, for removal: This API element is subject to removal in a future version. -
writeOutput
Deprecated, for removal: This API element is subject to removal in a future version. -
get
-
getKeys
CompletableFuture<HandlerContext.Handle<Collection<String>>> getKeys() -
clear
-
clearAll
CompletableFuture<Void> clearAll() -
set
-
timer
-
call
@Deprecated default CompletableFuture<HandlerContext.CallHandles> call(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable Collection<Map.Entry<String, String>> headers) Deprecated. -
call
CompletableFuture<HandlerContext.CallHandles> call(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers) -
send
@Deprecated default CompletableFuture<HandlerContext.Handle<String>> send(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable Collection<Map.Entry<String, String>> headers, @Nullable Duration delay) Deprecated. -
send
CompletableFuture<HandlerContext.Handle<String>> send(Target target, Slice parameter, @Nullable String idempotencyKey, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers, @Nullable Duration delay) -
submitRun
CompletableFuture<HandlerContext.Handle<Slice>> submitRun(@Nullable String name, Consumer<HandlerContext.RunCompleter> closure) -
awakeable
CompletableFuture<HandlerContext.Awakeable> awakeable() -
resolveAwakeable
-
rejectAwakeable
-
promise
-
peekPromise
-
resolvePromise
-
rejectPromise
-
signal
-
resolveSignal
-
rejectSignal
-
cancelInvocation
-
attachInvocation
-
getInvocationOutput
-
fail
-
await
Await the given future tree, until either one of its singles completes, or the invocation is cancelled or aborted.At most one single is completed per invocation of this method: when it returns
HandlerContext.AwaitResult.AnyCompleted, the caller MUST store the result in the returned single, otherwise it is lost. The caller should then re-evaluate the tree, and invoke this method again until the tree is completed.The tree is read concurrently while the returned future is not completed, and MUST NOT be modified in the meantime. Nodes that are already done are skipped, and invoking this method on a tree that is already done is an error.
-