Concept
You interact with actors through a*PID. You donβt need to know whether the actor is local (same process) or remote (
another node). The same Tell/Ask APIs work in both cases.
How it works
- Local β Message is enqueued directly into the actorβs mailbox.
- Remote β Message is serialized, sent over TCP, deserialized on the target node, and enqueued there.
pid.Tell(msg) or pid.Ask(ctx, msg, timeout) regardless of location.
The Path interface
pid.Path() returns a Path interfaceβthe location-transparent actor identity:
Path() for host, port, name, and string representation. Guard for nil when the sender is unknown (e.g.,
NoSender).
When location matters
Usepid.IsLocal() or pid.IsRemote() when you need location-specific behavior (e.g., avoiding remote calls for hot
paths, or logging).
ActorOf
ActorOf(ctx, name) returns a *PID whether the actor is local or remote. The framework looks up the actor in the
local tree first, then in the cluster registry. You get a unified handle either way.