Package dev.gmitch215.bytebox.binding
Interface DurableObjectNamespace
- All Superinterfaces:
org.teavm.jso.JSObject
public interface DurableObjectNamespace
extends org.teavm.jso.JSObject
A Durable Object binding. Declared with
durableObject(), named DO_ followed by
the class name.
One instance per id, in one location, with storage of its own. Two requests for the same id reach the same instance, which is what makes a Durable Object the place to put state that has to be consistent.
DurableObjectStub counter = env.durableObject("DO_COUNTER").byName("global");
Response current = counter.fetch(request);
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn instance's identity.static interfaceA handle on one instance. -
Method Summary
Modifier and TypeMethodDescriptionThe stub for a name, in one step.The stub for an id, which is a handle rather than a round trip.idFromName(String name) The id for a name, which is stable: the same name always gives the same id.idFromString(String hex) Parses an id previously produced byDurableObjectNamespace.DurableObjectId.asString().Returns a fresh id nothing has used, placed near whoever asked for it.Methods inherited from interface org.teavm.jso.JSObject
cast
-
Method Details
-
idFromName
The id for a name, which is stable: the same name always gives the same id.- Parameters:
name- the name- Returns:
- the id
-
idFromString
Parses an id previously produced byDurableObjectNamespace.DurableObjectId.asString().- Parameters:
hex- the id as hexadecimal- Returns:
- the id
-
newUniqueId
DurableObjectNamespace.DurableObjectId newUniqueId()Returns a fresh id nothing has used, placed near whoever asked for it.- Returns:
- a fresh id nothing has used, placed near whoever asked for it
-
get
The stub for an id, which is a handle rather than a round trip.- Parameters:
id- the id- Returns:
- the stub
-
byName
The stub for a name, in one step.- Parameters:
name- the name- Returns:
- the stub
-