CoAkka Runtime · Go v3.3.2
Configure CoAkka Runtime with Go
Start with Embedded and the defaults. Use this reference when you need to understand each field, choose peer modes or inspect the settings in effect.
What are you setting up?
Startup configurationConnectorStartSpec
SystemName- Logical system name. Choose a stable name that identifies the system across runs.
NodeID- Identifies a CoAkka Runtime instance. Give each instance in a system its own ID.
Routes- Initial route table. Add a route for new work or change it when a handler moves.
Generation- Route table version. Go resolves omitted or zero to 1. Use a newer generation when applying an updated table.
Network- Controls network participation. Beginner uses
EmbeddedNetwork(). Choose peer modes in the Advanced episode. StrictNoDrop- Set
truewhen you need visible rejection under overload. Read the accepted value throughStartupConfig(). QueueCapacity- Startup queue capacity. Omit or use zero for Core's bounded default. Tune after observing pressure and wait times.
Monitor- Startup monitoring group.
nilselects Core's default. OverloadPolicy- Group for overload behavior. Omit it for the default policy and read effective values through
RuntimeConfig(). ConnectionStrategy- TCP connection strategy between peers.
nilasks Core to selectMULTIPLEXING. A non-nil spec whoseModeis zero explicitly requestsPER_EXCHANGE. Check capabilities before choosing a mode or custom limits. Security- TCP security group. Omit it for Core's plaintext mode. Check capabilities and configure TLS or mTLS for your deployment.
runtimeLibPath- Second argument of
StartRuntimeHost. Use an empty string for normal package setup. An explicit library must match the connector.
Network modesRuntimeNetworkConfig
ModeEmbeddedNetwork()uses local routes within one process.OutboundOnlyNetwork()lets a caller connect out.NetworkNode(...)opens a listener that peers can reach.BindHost- Local IPv4 address for the listener. Episode 5 uses
127.0.0.1to stay on the same machine. BindPort- Port the listener opens. Episode 5 uses
19301. AdvertiseHost- Address peers use to connect. Choose a concrete address reachable from the peer.
AdvertisePort- Port peers connect to. Use the advertised host and port in the caller's route.
Routes and endpointsRouteSpec · EndpointSpec
Target- Name of the work in the route table, such as
orders.quote. Endpoints- Places that can handle the target. Episode 5 declares one endpoint on checkout.
Strategy- How CoAkka Runtime selects an endpoint. Use
RouteStrategySingleOwnerfor the single quote owner. Multi-endpoint examples can choose another strategy. RouteKeyHint- Name of the header carrying the routing key for
RouteStrategyRendezvousHash. Leave it empty in the single-owner example. RouteSpec.Flags- Route-level flags such as preferring a local endpoint. The examples use zero and follow the selected route strategy.
Host- Endpoint host. Checkout uses pricing's
127.0.0.1. Port- Endpoint port. Use the advertised port for a peer.
LocalRouteDefaultsets zero for in-process routes. Weight- Relative weight for a weighted strategy. The one-endpoint example uses 1.
EndpointSpec.FlagsEndpointFlagLocalmarks an in-process handler.EndpointFlagNoneis an ordinary peer endpoint.EndpointFlagUnavailableexcludes the endpoint from new work.
Pressure and monitoringRuntimeOverloadPolicy · RuntimeMonitorOptions
IngressMode- Policy for admitting additional work at ingress.
LocalDeliveryMode- Policy for work entering the local handler queue.
RemoteOutboundMode- Policy for work entering the queue for remote delivery.
RemoteOutboundReplyReserveSlots- Slots reserved for replies in the remote outbound queue. Read the effective count through
RuntimeConfig()before tuning. Enabled- Field of
RuntimeMonitorOptions. Settruefor extra monitoring data.falsedisables extra collection.
Extra monitor collection is off by default. Choose it before creating the instance, then read Core's accepted settings to confirm it. Monitoring does not create dashboards, storage or alerts; the application owns those concerns.
Read the shared operations contract · Run the Go monitoring lesson · When to enable monitoring and how to read its data
Connection strategyRuntimeTCPConnectionStrategySpec
Mode- Controls creation and reuse of connections. Omit the whole
ConnectionStrategyto keep Core'sMULTIPLEXINGdefault; do not create a zero-value spec unless you intend to selectPER_EXCHANGE. MaxConnections- Limit on retained pool connections. Set it only when the mode and effective capability allow tuning.
MaxRequestsPerConnection- Request limit before a connection retires. Omit it for the applicable Core value.
IdleTimeoutMillis- Idle connection lifetime in milliseconds. Tune it with the pool policy when capabilities allow.
TCP securityRuntimeTCPSecuritySpec
Mode- Choose plaintext, TLS or mTLS according to connection policy and package capabilities.
ReloadMode- Controls what happens to existing connections when credentials are reloaded.
CredentialGeneration- Credential revision. Start with a nonzero value and increase it when replacing active credentials.
CredentialID- A non-secret credential identifier. The TLS contract caps it at 127 bytes.
CACertificateFile- PEM trust roots used to verify peers.
IdentityCertificateFile- PEM certificate chain for this instance's identity.
PrivateKeyFile- Path to the private key matching the identity certificate chain.
Request parametersAskPayload
source- Logical caller name. The first episode uses
first-run. target- Name of the requested work. Match the declared route and handler.
payload- Application bytes sent to the handler. Agree on how the caller and handler interpret them.
timeout- Time budget for the request. The lab uses
2*time.Second. Choose it to match your application's requirements. deliveryHint- Constraint on delivery placement.
DeliveryHintRouterDefaultfollows the current route.
Read the effective configuration
Create config-lab/main.go in the module from episode 1. Paste the full file and run the command below. The lab turns on monitoring and chooses queue capacity 64 to show what Core accepts.
package main
import (
"errors"
"fmt"
"os"
coakka "github.com/phuong-tran/coakka-runtime-go/v3"
)
func run() (err error) {
host, err := coakka.StartRuntimeHost(coakka.ConnectorStartSpec{
SystemName: "configuration-lab",
NodeID: "configuration-lab-1",
Routes: []coakka.RouteSpec{coakka.LocalRouteDefault("orders.quote")},
Network: coakka.EmbeddedNetwork(),
StrictNoDrop: true,
QueueCapacity: 64,
Monitor: &coakka.RuntimeMonitorOptions{Enabled: true},
}, "")
if err != nil {
return err
}
defer func() {
err = errors.Join(err, host.Close())
}()
startup, err := host.StartupConfig()
if err != nil {
return err
}
active, err := host.RuntimeConfig()
if err != nil {
return err
}
fmt.Printf("generation=%d queue_capacity=%d strict_no_drop=%t monitor=%t bind_port=%d\n",
active.AppliedGeneration, startup.QueueCapacity, startup.StrictNoDrop,
startup.Monitor.Enabled, active.TransportBindPort)
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
go run -mod=readonly ./config-lab
Lab output
generation=1 queue_capacity=64 strict_no_drop=true monitor=true bind_port=0
Remove QueueCapacity and run it again to read Core's default. StartupConfig() reports the accepted startup settings. RuntimeConfig() reports the applied generation and bound port. In Embedded mode, bind_port=0 reflects that the lab runs in one process. Compare requested, accepted and effective state.