env.<BINDING> is your handle to an actor class. You name an instance, get a stub,
and call methods on it.
Two Ways to Name an Instance
idFromName(name)is deterministic: the samenamealways lands on the same instance, from anywhere. This is the common case — pick a stable identity for the entity and let the platform route to its state.newUniqueId()mints a fresh, unguessable instance; you store the id (stub.id) yourself. It currently fails at call time on the platform (a known runtime issue — see Actor Namespace); until it’s fixed, mint an identity yourself and pass it toidFromName.
Choosing a Name
The name is your shard key — choose the entity’s natural identity: a caller’s E.164 number, a user or account id, a room id, or a composite key (tenant:room). Same name →
same single-threaded instance → coherent state for that entity. Spreading load means
choosing names that spread across entities; a single hot name is one single-threaded
bottleneck (see When to use).
Calling the Stub
Both calls return a stub. Calling a method on the stub is an RPC to that one instance: the call is queued there, your method runs, the value comes back.Next Steps
- How it works — why one-instance-per-name gives coherent state
- Project structure — declaring the binding in
telnyx.toml - Runtime API —
ActorNamespaceandActorStub