CoAkka Runtime · Go v3.3.2
CoAkka Runtime · Go cheat sheet
Open the task you need, copy a short pattern, then return to the complete file when you need to check the full lifecycle.
This page targets Go connector v3.3.2. 3.3 identifies the Core generation; 2 is the Go connector revision on that generation. The exact install command is go get github.com/phuong-tran/coakka-runtime-go/[email protected].
01 · Prepare the project
Install the connector from the official Go channel
Create a new module and pin the release. The portal keeps the install command and version scope on this page; pkg.go.dev is only an optional release cross-check .
mkdir coakka-go-demo
cd coakka-go-demo
go mod init example.com/coakka-go-demo
go get github.com/phuong-tran/coakka-runtime-go/[email protected]
02 · Beginner
Start Embedded in one process
Keep the caller and handler in the same application. Core does not open a network listener in this mode.
host, err := coakka.StartRuntimeHost(coakka.ConnectorStartSpec{
SystemName: "quote-demo",
NodeID: "quote-demo-node",
Routes: []coakka.RouteSpec{coakka.LocalRouteDefault("orders.quote")},
Network: coakka.EmbeddedNetwork(),
}, "")
Keep one host for the application lifecycle and always close it on the cleanup path. See the complete main.go.
03 · Request/reply
Register a handler and call the work
err = host.RegisterPayloadHandler("orders.quote", quote)
reply, err := host.AskPayload(
"checkout",
"orders.quote",
[]byte("3"),
2*time.Second,
coakka.DeliveryHintRouterDefault,
)
source- Logical name of the caller.
target- Work name; it must match the route and handler.
payload- Application data as bytes.
timeout- Maximum duration of the call.
deliveryHint- Use
RouterDefaultto follow the current route.
04 · Advanced
Move the handler to a peer
Handler process
Use NetworkNode to open a listener and advertise the same address for this loopback lesson.
Network: coakka.NetworkNode(
"127.0.0.1", 19301,
"127.0.0.1", 19301,
)
Caller process
Use OutboundOnlyNetwork(); the route endpoint points at the address advertised by the peer.
Network: coakka.OutboundOnlyNetwork()
go run -mod=readonly ./quote-service
go run -mod=readonly ./checkout
05 · Advanced data lane
Use File Lane for one immutable file
Choose File Lane when the sender already has a stable file and the receiver needs its exact size, SHA-256, observable progress, controlled resume/cancel and terminal outcomes on both peers. Do not put file bytes in a message payload or use File Lane to fetch directly from S3, HTTPS or another external source.
- Compute the stable source's size and SHA-256.
- The receiver prepares the exact destination, identity and token first.
- The app control plane gives the capability to the exact sender and never logs the token.
- The sender submits; observe send and receive independently until terminal.
- Record both outcomes, then
Forgetrecords andClosethe lane.
go run -mod=readonly ./file-lane
Read the shared contract and parameters · Open the complete File Lane example · Look up File Lane
06 · Advanced data lane
Use Stream Lane for live frames
Choose Stream Lane for one ordered, bounded binary-frame sequence from one publisher to one subscriber. Use File Lane for an immutable file that needs SHA-256. Fan-out, durable replay, schemas, WebSocket protocol and application policy remain app-host responsibilities.
- The application fixes the
FormatID, frame bound and window bound. - The publisher prepares the session and source callback before the subscriber connects.
- Copy bytes that must survive after the consumer callback returns.
- Observe publish and subscribe independently until terminal; inspect pressure when needed.
Forgetrecords after recording outcomes, thenClosefrom the owner.
go run -mod=readonly ./stream-lane
Read the shared contract and parameters · Open the complete Stream Lane example · Look up Stream Lane
07 · Diagnose
Read the outcome before changing settings
ROUTE_MISS- Core found no route for the target. Compare the target in the deadletter with the route table and handler name.
TRANSPORT_SEND_FAILED- The route selected a peer but could not send. Check the peer process, host and advertised port.
08 · Configuration
Read the configuration Core accepted
StartupConfig() returns the accepted startup settings. RuntimeConfig() returns applied state such as the generation and actual bound port.
go run -mod=readonly ./config-lab
09 · Operations
Enable monitoring when you need extra observations
Core keeps extra monitor collection off by default to avoid additional CPU, memory and coordination work when the application does not need diagnostic data. Health, counters and accepted configuration remain readable without reconstructing them from startup input.
- When to enable it
- For a state dashboard, queue depth, rejection counts or recent diagnostic information.
- When to leave it off
- When occasional health and counter reads are enough, especially on small or latency-sensitive hosts.
- When to choose
- Set
Monitor.Enabledbefore creating the instance. The same instance has no live ON/OFF switch. - How to confirm
- Read Core's accepted settings; a supported capability does not mean collection is enabled.
- Boundary
- Each monitor observes one instance. The application owns export, storage, dashboards and alerts.
- How to read
- Compare counters over time; do not use “no update” as a health check or bounded history as an audit log.
go run -mod=readonly ./monitoring
Read the shared health, stats and Monitor contract · Open the complete monitoring file and verified output · Look up monitoring and overload fields · Run the accepted-settings lab
10 · Integration
Checklist for adding CoAkka Runtime to an application
- Create one host for the lifetime of the service, job, CLI or application process; do not create a host per request.
- Keep business logic in the handler and keep the target stable when the handler moves.
- Consume a reply or deadletter at the call site; retry remains application business policy.
- Keep Core defaults unless capabilities and measurements justify another setting.
- Stop admitting new work, finish in-flight work and close the host from the owner that created it.
Open the complete integration file · See when the handler moves to a peer