client package provides a standalone client for interacting with a GoAkt cluster from outside the actor system. Use it when your application (CLI, API server, batch job, etc.) needs to send messages to actors or grains, spawn actors, or query cluster state without running an actor system itself.
Requirements
- Cluster with remoting — Target nodes must run GoAkt with clustering and remoting enabled.
- At least one node —
client.Newrequires a non-empty slice of nodes; it fails with “nodes are required” otherwise. - Node addresses — Each node is specified as
host:port(remoting host and port, e.g.127.0.0.1:8080). Addresses are validated as TCP addresses. - Serialization — The client must use the same serializers and compression as the cluster. Pass
remote.ConfigviaWithRemoteConfigwhen creating nodes. Without it, the node uses default remoting settings, which may not match the cluster.
Creating a client
Node represents a cluster node. Call Close() when done to release connection pools. The client uses a load balancer to distribute requests across nodes. The remote.Config must match the cluster (compression, serializers).
Node options
Messaging
The client performs a cluster lookup by actor name (or grain identity) and routes the message to the correct node. For grains, use
remote.GrainRequest{Name: "id", Kind: "MyGrain"}. Name and Kind are required and are trimmed of whitespace.
Spawning and lifecycle
The actor kind must be registered on the cluster via
WithKinds when creating the actor system. SpawnRequest requires Name and Kind; optional fields include Singleton, Relocatable, PassivationStrategy, Supervisor, Dependencies, EnableStashing, Role, and Reentrancy.
Discovery and inspection
Options
Balancer strategies
Thread safety
The client is safe for concurrent use by multiple goroutines.Errors
See also
- Remoting — Cluster remoting configuration
- Serialization — Message serialization (client must match cluster)
- Code Map —
client/package overview