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.

Version scope

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].

Cross-check the package catalog on GitHub (optional)

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 .

Terminal
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]

Check Go, cgo and the compiler before installing

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.

Startup pattern
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

Call pattern
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 RouterDefault to follow the current route.

Read every AskPayload parameter

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()
Terminal 1 · Terminal 2
go run -mod=readonly ./quote-service
go run -mod=readonly ./checkout

See both complete files and the stop/restart peer exercise

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.

  1. Compute the stable source's size and SHA-256.
  2. The receiver prepares the exact destination, identity and token first.
  3. The app control plane gives the capability to the exact sender and never logs the token.
  4. The sender submits; observe send and receive independently until terminal.
  5. Record both outcomes, then Forget records and Close the lane.
Terminal
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.

  1. The application fixes the FormatID, frame bound and window bound.
  2. The publisher prepares the session and source callback before the subscriber connects.
  3. Copy bytes that must survive after the consumer callback returns.
  4. Observe publish and subscribe independently until terminal; inspect pressure when needed.
  5. Forget records after recording outcomes, then Close from the owner.
Terminal
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.

Look up deadletter · Run the deliberate route-miss lesson

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.

Terminal
go run -mod=readonly ./config-lab

Open the complete configuration lab · Choose fields by task

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.Enabled before 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.
Terminal
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

  1. Create one host for the lifetime of the service, job, CLI or application process; do not create a host per request.
  2. Keep business logic in the handler and keep the target stable when the handler moves.
  3. Consume a reply or deadletter at the call site; retry remains application business policy.
  4. Keep Core defaults unless capabilities and measurements justify another setting.
  5. 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