Skip to main content
A PID is the sole actor reference in GoAkt. It is a live handle to a running actorβ€”either local (same process) or remote (another node). All messaging goes through a PID.

Role

AspectDescription
Unified referenceOne type for local and remote actors. No separate ActorRef.
Location-transparentUse Tell and Ask the same way regardless of location.
IdentityPath() returns the canonical address. Name(), Kind() identify the actor.

Local vs Remote

TypeDescription
Local PIDLive mailbox, supervision state, full actor-system reference, etc… Created by Spawn.
Remote PIDLightweight handle with address and remoting; messaging via remoting layer. Returned by ActorOf when actor is on another node.
Use pid.IsLocal() or pid.IsRemote() when location matters. pid.ActorSystem() returns nil for remote PIDsβ€”guard before use.

Key methods

MethodPurpose
Path()Canonical actor identity (host, port, name, system). Returns Path interface.
Name()Actor name within its parent.
Kind()Reflected type name of the actor. Empty for remote PIDs.
Tell(ctx, to, message)Fire-and-forget to another PID.
Ask(ctx, to, message, timeout)Request-response. Blocks until reply or timeout.
IsRunning()Actor is active and processing.
IsSuspended()Actor suspended by supervisor.
IsStopping()Shutdown in progress.
Watch(cid)Receive Terminated when cid stops. Local only.
UnWatch(cid)Stop watching.

Obtaining a PID

  • Spawn β€” system.Spawn(ctx, name, actor) returns a local PID.
  • ActorOf β€” system.ActorOf(ctx, name) returns local or remote PID.
  • Context β€” ctx.Self() (current actor), ctx.Sender() (message sender).

NoSender

system.NoSender() returns a special PID for messages without a sender (e.g., scheduled messages, external clients). Use it when sending from outside the actor system. NoSender().Path() may be used for wire encoding.