Package dev.restate.sdk
Interface ObjectContext
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear(dev.restate.sdk.common.StateKey<?> key)Clears the state stored under key.voidclearAll()Clears all the state of this virtual object instance key-value state storagestatic ObjectContextcurrent()Create aObjectContext.static ObjectContextfromSyscalls(dev.restate.sdk.common.syscalls.Syscalls syscalls)Build a RestateContext from the underlyingSyscallsobject.<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.<T> voidset(dev.restate.sdk.common.StateKey<T> key, T value)Sets the given value under the given key, serializing the value using theSerdein theStateKey.java.util.Collection<java.lang.String>stateKeys()Gets all the known state keys for this virtual object instance.-
Methods inherited from interface dev.restate.sdk.Context
awakeable, awakeableHandle, call, call, call, delayedCall, delayedCall, delayedCall, grpcChannel, oneWayCall, oneWayCall, oneWayCall, random, sideEffect, sideEffect, sleep, timer
-
-
-
-
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 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.
-
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 theSerdein theStateKey.- 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 aObjectContext. 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 underlyingSyscallsobject.
-
-