Interface Restate.State

Enclosing class:
Restate

@Experimental public static interface Restate.State
EXPERIMENTAL API: Interface to interact with this Virtual Object/Workflow state.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(StateKey<?> key)
    EXPERIMENTAL API: Clears the state stored under key.
    void
    EXPERIMENTAL API: Clears all the state of this virtual object instance key-value state storage
    <T> Optional<T>
    get(StateKey<T> key)
    EXPERIMENTAL API: Gets the state stored under key, deserializing the raw value using the Serde in the StateKey.
    EXPERIMENTAL API: Gets all the known state keys for this virtual object instance.
    <T> void
    set(StateKey<T> key, @NonNull T value)
    EXPERIMENTAL API: Sets the given value under the given key, serializing the value using the Serde in the StateKey.
  • Method Details

    • get

      @Experimental <T> Optional<T> get(StateKey<T> key)
      EXPERIMENTAL API: Gets the state stored under key, deserializing the raw value using the Serde in the StateKey.
      Parameters:
      key - identifying the state to get and its type.
      Returns:
      an Optional containing the stored state deserialized or an empty Optional if not set yet.
      Throws:
      RuntimeException - when the state cannot be deserialized.
    • set

      @Experimental <T> void set(StateKey<T> key, @NonNull T value)
      EXPERIMENTAL API: Sets the given value under the given key, serializing the value using the Serde in the StateKey.
      Parameters:
      key - identifying the value to store and its type.
      value - to store under the given key. MUST NOT be null.
      Throws:
      IllegalStateException - if called from a Shared handler
    • clear

      @Experimental void clear(StateKey<?> key)
      EXPERIMENTAL API: Clears the state stored under key.
      Parameters:
      key - identifying the state to clear.
      Throws:
      IllegalStateException - if called from a Shared handler
    • getAllKeys

      @Experimental Collection<String> getAllKeys()
      EXPERIMENTAL API: Gets all the known state keys for this virtual object instance.
      Returns:
      the immutable collection of known state keys.
    • clearAll

      @Experimental void clearAll()
      EXPERIMENTAL API: Clears all the state of this virtual object instance key-value state storage
      Throws:
      IllegalStateException - if called from a Shared handler