This guide walks through the flow of creating an actor system, spawning an actor, and sending messages. For the full ActorSystem API and configuration, see Actor System.Documentation Index
Fetch the complete documentation index at: https://docs.goakt.dev/llms.txt
Use this file to discover all available pages before exploring further.
Flow
- Create an actor system with
NewActorSystemandStart - Spawn an actor with
Spawn(ctx, name, actor)→ receive a*PID - Send messages with
NoSender().Tell(fire-and-forget) orNoSender().Ask(request-response) - Shutdown with
Stopwhen the application exits
Actor interface
Implement theActor interface to define your actor. See Actor Model
for the full interface and method explanations.
Messaging from outside
From outside the actor system (e.g.,main), use NoSender() to send:
- Tell — Fire-and-forget. No response expected.
- Ask — Request-response. Blocks until reply or timeout. The actor must call
ctx.Response(resp)to complete the request.
Replying from an actor
When handling a message sent viaAsk, call ctx.Response(resp) exactly once. The caller receives that value. For
Tell, no reply is expected.
ReceiveContext
InsideReceive, ctx provides:
| Method | Purpose |
|---|---|
Message() | The message being processed |
Sender() | PID of the sender (nil for scheduled or system messages) |
Self() | PID of the current actor |
Tell(to, msg) | Send fire-and-forget to another actor |
Ask(to, msg, timeout) | Send request-response |
Response(resp) | Reply to an Ask |
Unhandled() | Mark message as unhandled |