Interface StateMachine
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
LegacyStateMachine
Canonical state-machine contract driving a single Restate invocation.
This is shaped after the restate-sdk-shared-core VM trait.
It is implemented twice, selected at runtime by StateMachineFactory:
- a Panama/FFM implementation calling the native
restate-sdk-shared-corelibrary, used on JDK 23+ — the path that supports the latest Restate features; - a pure-Java implementation (the legacy state machine) used on JDK < 23, or when the native library is unavailable/disabled — a deprecated fallback that will be removed in a future release.
Instances of this interface are not thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic final recordstatic final recordstatic final recordstatic enumstatic interfacestatic final record -
Method Summary
Modifier and TypeMethodDescriptionintattachInvocation(String invocationId) call(Target target, Slice payload, @Nullable String idempotencyKey, @Nullable String scope, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers) voidcancelInvocation(String targetInvocationId) voidclose()voidcompleteAwakeable(String awakeableId, Slice value) voidcompleteAwakeable(String awakeableId, TerminalException exception) voidcompleteSignal(String targetInvocationId, String signalName, Slice value) voidcompleteSignal(String targetInvocationId, String signalName, TerminalException exception) intcreateSignalHandle(String signalName) doAwait(UnresolvedFuture future) Make progress on the still-uncompleted await tree rooted atfuture, or returnnullwhen nothing is left to await (every node already resolved).voidend()intgetInvocationOutput(String invocationId) input()booleanvoidnotifyError(Throwable throwable) voidnotifyInput(Slice bytes) Feed the next chunk of wire input.voidintpromiseComplete(String key, Slice value) intpromiseComplete(String key, TerminalException exception) intpromiseGet(String key) intpromisePeek(String key) voidproposeRunCompletion(int handle, Slice value) voidproposeRunCompletion(int handle, TerminalException terminalException) voidproposeRunCompletion(int handle, Throwable exception, Duration attemptDuration, @Nullable RetryPolicy retryPolicy) intsend(Target target, Slice payload, @Nullable String idempotencyKey, @Nullable String scope, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers, @Nullable Duration delay) intstate()voidstateClear(String key) voidintintvoid@Nullable StateMachine.NotificationValuetakeNotification(int handle) Drain the next chunk of serialized output ready for the wire, orSlice.EMPTYwhen nothing is buffered.voidwriteOutput(Slice value) voidwriteOutput(TerminalException exception)
-
Method Details
-
getResponseContentType
String getResponseContentType() -
notifyInput
Feed the next chunk of wire input. -
notifyInputClosed
void notifyInputClosed() -
notifyError
-
takeOutput
Slice takeOutput()Drain the next chunk of serialized output ready for the wire, orSlice.EMPTYwhen nothing is buffered. -
isReadyToExecute
boolean isReadyToExecute() -
doAwait
Make progress on the still-uncompleted await tree rooted atfuture, or returnnullwhen nothing is left to await (every node already resolved).On suspension this does not return a value: it sneaky-throws
AbortedExecutionException, which should be treated as a clean abort of the user code, not a failure to re-report. -
takeNotification
-
input
StateMachine.Input input() -
stateGet
-
stateGetKeys
int stateGetKeys() -
stateSet
-
stateClear
-
stateClearAll
void stateClearAll() -
sleep
-
call
StateMachine.CallHandle call(Target target, Slice payload, @Nullable String idempotencyKey, @Nullable String scope, @Nullable String limitKey, @Nullable Collection<Map.Entry<String, String>> headers) -
send
-
awakeable
StateMachine.Awakeable awakeable() -
completeAwakeable
-
completeAwakeable
-
createSignalHandle
-
completeSignal
-
completeSignal
-
promiseGet
-
promisePeek
-
promiseComplete
-
promiseComplete
-
run
-
proposeRunCompletion
-
proposeRunCompletion
-
proposeRunCompletion
void proposeRunCompletion(int handle, Throwable exception, Duration attemptDuration, @Nullable RetryPolicy retryPolicy) -
cancelInvocation
-
attachInvocation
-
getInvocationOutput
-
writeOutput
-
writeOutput
-
end
void end() -
close
void close()- Specified by:
closein interfaceAutoCloseable
-
state
StateMachine.InvocationState state()
-