CoAkka Runtime · C#/.NET 3.3.2
Cheat sheet CoAkka Runtime · C#/.NET
Tra nhanh NuGet coordinate, API shape, outcome và lifecycle; mở bài đầy đủ khi cần failure law.
Version và package
Project
<PackageReference Include="CoAkka.Runtime" Version="3.3.2" />- Connector
3.3.2: Core generation 3.3, connector revision 2.- Framework
net8.0cho bài học.- Native RID assets
- macOS ARM64, Linux ARM64/x64, Windows ARM64/x64. Support claim cần exact package + OS + CPU evidence.
- Owner
RuntimeHost; dùngawait usinghoặcDisposeAsyncđúng app lifecycle.
Embedded request/reply
C#
await using var runtime = RuntimeHost.StartLocal(
systemName: "orders",
target: "orders.quote",
nodeId: "orders-1");
runtime.RegisterTextHandler("orders.quote", quantity => Quote(quantity));
var reply = await runtime.AskTextAsync(
source: "checkout",
target: "orders.quote",
payload: "2",
timeoutMs: 2_000);Outcome và Deadletter
- Reply
AskTextAsync,AskAsynctrả terminal response đã correlation.- Deadletter
DeadletterException.Deadlettergiữ reason, original envelope, generation và delivery failure facts.- Timeout/cancel
- Failure boundary riêng; không chứng minh handler chưa chạy.
- OneWay
SendOneWay*không chờ business response nhưng vẫn có admission/observability evidence.- Classification
- Dùng typed exception, enum và stable numeric code; không parse message text.
Peer trực tiếp
Service
Network = RuntimeNetworkConfig.NetworkNode(
bindHost: "0.0.0.0",
bindPort: 19_321,
advertiseHost: "pricing.internal",
advertisePort: 19_321)Caller
Network = RuntimeNetworkConfig.OutboundOnly(),
Routes = [new RuntimeRouteSpec(
Target: "orders.quote",
Endpoints: [new RuntimeEndpointSpec("pricing.internal", 19_321, 1)],
Strategy: RuntimeRouteStrategy.SingleOwner)]File Lane và Stream Lane
- File: hash → receiver grant → sender submit → hai terminal OK → forget → dispose.
- Stream: publisher grant → subscriber window → callbacks bounded → hai terminal OK → forget → dispose.
- Grant gắn exact owner; không load-balance qua Service address.
Span<byte>/ReadOnlySpan<byte>chỉ borrow trong callback; copy trước khi retain.- Lane owner độc lập với
RuntimeHost; không dispose trong chính callback.
Monitor và effective state
EnableMonitor = true- Startup intent.
StartupConfig()- Core accepted Monitor/default facts.
Health()/Stats()- Observed runtime state và counters.
RuntimeConfig()- Generation, routes, state và transport bind facts.
- API boundary
- C# 3.3.2 chưa chiếu Monitor wait API; không copy method từ connector khác.
Checklist tích hợp
- Ghim exact NuGet version; kiểm tra RID asset thực tế.
- Một
RuntimeHosttheo app lifecycle, không tạo theo request. - Dùng named arguments cho constructors/calls nhiều tham số.
- Chờ mọi operation/callback kết thúc trước shutdown.
- Đọc capability/effective state trước advanced transport hoặc tuning.
- File/Stream Lane có lifecycle riêng; giữ delegate tới confirmed retirement.
- Blocking lane waits chạy ngoài UI thread.