Interface ObjectContext

  • All Superinterfaces:
    Context

    @NotThreadSafe
    public interface ObjectContext
    extends Context
    This interface extends Context adding access to the virtual object instance key-value state storage
    See Also:
    Context
    • Method Detail

      • get

        <T> java.util.Optional<T> get​(dev.restate.sdk.common.StateKey<T> key)
        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:
        java.lang.RuntimeException - when the state cannot be deserialized.
      • stateKeys

        java.util.Collection<java.lang.String> stateKeys()
        Gets all the known state keys for this virtual object instance.
        Returns:
        the immutable collection of known state keys.
      • clear

        void clear​(dev.restate.sdk.common.StateKey<?> key)
        Clears the state stored under key.
        Parameters:
        key - identifying the state to clear.
      • clearAll

        void clearAll()
        Clears all the state of this virtual object instance key-value state storage
      • set

        <T> void set​(dev.restate.sdk.common.StateKey<T> key,
                     @Nonnull
                     T value)
        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.
      • current

        static ObjectContext current()
        Create a ObjectContext. This will look up the thread-local/async-context storage for the underlying context implementation, so make sure to call it always from the same context where the service is executed.
      • fromSyscalls

        static ObjectContext fromSyscalls​(dev.restate.sdk.common.syscalls.Syscalls syscalls)
        Build a RestateContext from the underlying Syscalls object.