StateMachine

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-core library, 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.

Inheritors

Types

Link copied to clipboard
interface AwaitResult
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class Input : Record
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
abstract fun attachInvocation(invocationId: String): Int
Link copied to clipboard
Link copied to clipboard
abstract fun call(target: Target, payload: Slice, @Nullable idempotencyKey: @Nullable String, @Nullable scope: @Nullable String, @Nullable limitKey: @Nullable String, @Nullable headers: @Nullable Collection<Map.Entry<String, String>>): StateMachine.CallHandle
Link copied to clipboard
abstract fun cancelInvocation(targetInvocationId: String)
Link copied to clipboard
abstract fun close()
Link copied to clipboard
abstract fun completeAwakeable(awakeableId: String, value: Slice)
abstract fun completeAwakeable(awakeableId: String, exception: TerminalException)
Link copied to clipboard
abstract fun completeSignal(targetInvocationId: String, signalName: String, value: Slice)
abstract fun completeSignal(targetInvocationId: String, signalName: String, exception: TerminalException)
Link copied to clipboard
abstract fun createSignalHandle(signalName: String): Int
Link copied to clipboard
Make progress on the still-uncompleted await tree rooted at future, or return null when nothing is left to await (every node already resolved).
Link copied to clipboard
abstract fun end()
Link copied to clipboard
abstract fun getInvocationOutput(invocationId: String): Int
Link copied to clipboard
Link copied to clipboard
abstract fun input(): StateMachine.Input
Link copied to clipboard
abstract fun isReadyToExecute(): Boolean
Link copied to clipboard
abstract fun notifyError(throwable: Throwable)
Link copied to clipboard
abstract fun notifyInput(bytes: Slice)
Feed the next chunk of wire input.
Link copied to clipboard
abstract fun notifyInputClosed()
Link copied to clipboard
abstract fun promiseComplete(key: String, value: Slice): Int
abstract fun promiseComplete(key: String, exception: TerminalException): Int
Link copied to clipboard
abstract fun promiseGet(key: String): Int
Link copied to clipboard
abstract fun promisePeek(key: String): Int
Link copied to clipboard
abstract fun proposeRunCompletion(handle: Int, value: Slice)
abstract fun proposeRunCompletion(handle: Int, terminalException: TerminalException)
abstract fun proposeRunCompletion(handle: Int, exception: Throwable, attemptDuration: Duration, @Nullable retryPolicy: @Nullable RetryPolicy)
Link copied to clipboard
Link copied to clipboard
abstract fun send(target: Target, payload: Slice, @Nullable idempotencyKey: @Nullable String, @Nullable scope: @Nullable String, @Nullable limitKey: @Nullable String, @Nullable headers: @Nullable Collection<Map.Entry<String, String>>, @Nullable delay: @Nullable Duration): Int
Link copied to clipboard
abstract fun sleep(duration: Duration, @Nullable name: @Nullable String): Int
Link copied to clipboard
Link copied to clipboard
abstract fun stateClear(key: String)
Link copied to clipboard
abstract fun stateClearAll()
Link copied to clipboard
abstract fun stateGet(key: String): Int
Link copied to clipboard
abstract fun stateGetKeys(): Int
Link copied to clipboard
abstract fun stateSet(key: String, bytes: Slice)
Link copied to clipboard
@Nullable
abstract fun takeNotification(handle: Int): @Nullable StateMachine.NotificationValue
Link copied to clipboard
abstract fun takeOutput(): Slice
Drain the next chunk of serialized output ready for the wire, or EMPTY when nothing is buffered.
Link copied to clipboard
abstract fun writeOutput(value: Slice)
abstract fun writeOutput(exception: TerminalException)