Package dev.restate.sdk
Interface SharedObjectContext
-
- All Superinterfaces:
Context
- All Known Subinterfaces:
ObjectContext,SharedWorkflowContext,WorkflowContext
public interface SharedObjectContext extends Context
This interface can be used only within shared handlers of virtual objects. It extendsContextadding access to the virtual object instance key-value state storage.NOTE: This interface MUST NOT be accessed concurrently since it can lead to different orderings of user actions, corrupting the execution of the invocation.
- See Also:
Context
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> java.util.Optional<T>get(dev.restate.sdk.common.StateKey<T> key)Gets the state stored under key, deserializing the raw value using theSerdein theStateKey.java.lang.Stringkey()java.util.Collection<java.lang.String>stateKeys()Gets all the known state keys for this virtual object instance.
-
-
-
Method Detail
-
key
java.lang.String key()
- Returns:
- the key of this object
-
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 theSerdein theStateKey.- Parameters:
key- identifying the state to get and its type.- Returns:
- an
Optionalcontaining the stored state deserialized or an emptyOptionalif 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.
-
-