Role and responsibilities
See Architecture Overview for the component diagram.
Lifecycle
- NewActorSystem — Applies options; does not start services.
- Start — Initializes remoting (if enabled), cluster (if enabled), scheduler, eviction, passivation, and system actors. Handle SIGTERM/SIGINT and call
Stopfor clean shutdown. - Stop — Runs coordinated shutdown hooks, stops user actors, deactivates grains, shuts down system actors, leaves cluster, stops remoting. Does not exit the process; call
os.Exitif needed.
API surface
Spawning
See Actor Lifecycle, Routers, Singletons, Clustering.
Resolution and inspection
See PID, Location Transparency.
Messaging from outside
From outside the actor system (e.g.main), use system.NoSender():
NoSender().Tell(pid, msg)— Fire-and-forget.NoSender().Ask(ctx, pid, msg, timeout)— Request-response; actor must callctx.Response(resp).
Scheduling
Use
WithReference(id) when scheduling if you need to cancel, pause, or resume. See Scheduling.
Events and observability
See Event Streams, PubSub, Observability.
Cluster and lifecycle control
Dependency injection
Configuration options
Options are passed toNewActorSystem(name, opts...). Each option is documented in the source; this table groups them by concern.
Component relationships
The ActorSystem composes:- Remoting — TCP server/client; used when
WithRemoteis set. - Cluster — Membership, discovery, Olric DMap; used when
WithClusteris set. - Event stream — In-process pub/sub; always present; topic actors when
WithPubSubis set. - Scheduler — For
ScheduleOnce,Schedule,ScheduleWithCron. - Extensions — Accessed via
ctx.Extension(id)from actors.
ctx.ActorSystem() (or ReceiveContext, GrainContext). Use it to spawn children, resolve actors, schedule, or access extensions. Do not store the ActorSystem in actor state; always obtain it from context.
Further reading
- First Actor — Minimal flow
- Actor Model — Actor interface and hierarchy
- Clustering — Standalone vs clustered vs multi-DC
- Reference: Interfaces — Interface definitions