Skip to main content
The ActorSystem is the top-level runtime that hosts actors and orchestrates messaging, clustering, remoting, and lifecycle. There is one ActorSystem per process. All actors, grains, and system services run within it.

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 Stop for 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.Exit if needed.
Details: Coordinated Shutdown, First Actor.

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 call ctx.Response(resp).
For processes that do not run an actor system (CLI, API server, batch job), use the Client package to connect to the cluster and send messages by actor name. See Messaging.

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 to NewActorSystem(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 WithRemote is set.
  • Cluster — Membership, discovery, Olric DMap; used when WithCluster is set.
  • Event stream — In-process pub/sub; always present; topic actors when WithPubSub is set.
  • Scheduler — For ScheduleOnce, Schedule, ScheduleWithCron.
  • Extensions — Accessed via ctx.Extension(id) from actors.
Actors obtain the system via 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