Reference theo việc cần làm · C# 3.3.2

Cấu hình CoAkka Runtime · C#/.NET

Public C# types chiếu Core contract thành .NET values. Dùng named arguments cho intent, rồi đọc snapshots thay vì báo lại input preference.

Package và lifecycleCoAkka.Runtime 3.3.2 · net8.0
RuntimeHost.StartLocal
Đường ngắn cho một local target.
RuntimeHost.Start
Explicit routes/network/transport. ConnectorOrchestrator là compatibility facade.
await using
Ưu tiên async shutdown để seal admission, chờ admitted read và join owners.
Handler bounds
256 handlers, 64 KiB UTF-8 labels; managed asks tối đa 64. Saturation là managed scheduling refusal, không phải Core status.
Trimmed apps
Dùng source-generated JsonTypeInfo overload hoặc payload bytes.
Startup intentConnectorStartSpec
SystemName / NodeId
Logical app-host và unique runtime owner identity.
Routes
Initial snapshot. RuntimeHost.LocalRoute(target) cho Embedded.
QueueCapacity = 0
Omission selector; Core normalizes và báo accepted capacity.
StrictNoDrop = true
Explicit safe intent của frozen ABI.
Generation
Monotonic route/control generation.
EnableMonitor = null
Omitted giữ Core default OFF; true/false là explicit intent.
Network
Omitted/Embedded cho local; explicit OutboundOnly/NetworkNode khi peer cần.
Network, route và endpointRuntimeNetworkConfig · RuntimeRouteSpec
Embedded()
Local-only, không listener.
OutboundOnly()
Remote caller không sở hữu listener.
NetworkNode(bindHost, bindPort, advertiseHost, advertisePort)
Bind/advertise tách biệt; endpoint phải reachable với peer.
Target
Business address giữ ổn định.
Endpoints
Candidate owners với host, port, weight, flags.
SingleOwner
Một owner; WeightedRoundRobin dùng weight; RendezvousHash dùng route key.
Weight
Relative selection weight, không phải retry/priority.

Tra routing · Tra failover/retry

Kết nối và securityRuntimeTcpConnectionStrategySpec · RuntimeTcpSecuritySpec
ConnectionStrategy = null
Omit group cho Core AUTO/current Multiplexing.
Mode
Explicit mode khi gửi spec; enum zero là PerExchange, không phải AUTO.
MaxConnections
Connection bound khi mode/capability áp dụng.
MaxRequestsPerConnection
Retirement bound theo request.
IdleTimeoutMs
Idle-retention bound.
Security.Mode
Plaintext/Tls/MutualTls; bundled Core 3.3 báo public TCP TLS/mTLS unavailable.
CredentialGeneration
Positive và tăng dần cho same-mode reload.
CredentialId
Non-secret diagnostic ID.
CA/cert/key
App sở hữu file lifecycle; snapshots không trả secret paths/material.

Tra connectivity/security contract.

File Lane và Stream LaneIndependent IDisposable owners
FileLane.OpenOwned
Exact receiver owner cấp grant; Sha256 trả size/digest.
WaitTransfer
Blocking; chạy ngoài UI thread. Success là terminal + Completed + Ok.
StreamLane.OpenOwned
Publisher cấp single-admission grant.
Span<byte>
Writable borrowed source buffer; không giữ qua callback.
ReadOnlySpan<byte>
Borrowed consumer view; copy trước khi retain.
Callback root
Connector giữ delegate tới confirmed retirement; cancel chưa tự retire.
Dispose()
Gọi từ external owner sau terminal/forget, không gọi trong chính callback.

Tra data-lane contract.

Đọc Core accepted/effective stateStartupConfig · RuntimeConfig · Health · Stats

Tạo Configuration.cs cạnh project và chọn nó bằng SampleFile.

Configuration.cs
using CoAkka.Runtime;

namespace CoAkkaPortal;

internal static class Configuration
{
    public static async Task Main()
    {
        const string target = "orders.quote";
        var startSpec = new ConnectorStartSpec(
            SystemName: "orders",
            NodeId: "config-csharp-1",
            Routes: [RuntimeHost.LocalRoute(target)],
            EnableMonitor: true);

        await using var runtime = RuntimeHost.Start(startSpec);
        var startup = runtime.StartupConfig();
        var config = runtime.RuntimeConfig();
        Console.WriteLine(
            $"generation={config.AppliedGeneration} " +
            $"queue_capacity={config.QueueCapacity} " +
            $"strict_no_drop={config.StrictNoDrop.ToString().ToLowerInvariant()} " +
            $"monitor={startup.MonitorEnabled.ToString().ToLowerInvariant()} " +
            $"state={config.RuntimeState}");
    }
}
Terminal
dotnet run -p:SampleFile=Configuration

Kết quả đã kiểm chứng

generation=1 queue_capacity=4096 strict_no_drop=true monitor=true state=Started
StartupConfig()
Accepted queue, execution, connection, I/O, Monitor và default groups.
RuntimeConfig()
Identity, generation, routes, runtime state và transport bind facts.
RuntimeCapabilities()
Feature truth trước advanced transport.
Health() / Stats()
Observed state và counters.

Requested, accepted, effective, observed.