feat: port session 10 — Server Core Runtime, Accept Loops & Listeners

Ports server/server.go lines 2577–4782 (~1,881 Go LOC), implementing ~97
features (IDs 3051–3147) across three new partial-class files.

New files:
- NatsServer.Lifecycle.cs: Shutdown, WaitForShutdown, RemoveClient,
  SendLDMToClients, LameDuckMode, LDMClientByID, rate-limit logging,
  DisconnectClientByID, SendAsyncInfoToClients
- NatsServer.Listeners.cs: AcceptLoop, GetServerListener, InProcessConn,
  AcceptConnections, GenerateInfoJson, CopyInfo, CreateClient/Ex/InProcess,
  StartMonitoring (HTTP/HTTPS), AddConnectURLs/RemoveConnectURLs,
  TlsVersion/TlsVersionFromString, GetClientConnectURLs, ResolveHostPorts,
  PortsInfo/PortFile/LogPorts, ReadyForListeners, GetRandomIP, AcceptError
- Internal/WaitGroup.cs: Go-style WaitGroup using TaskCompletionSource

Modified:
- Auth/AuthTypes.cs: Account now implements INatsAccount (stub)
- NatsServerTypes.cs: ServerInfo.ShallowClone(), removed duplicate RefCountedUrlSet
- NatsServer.cs: _info promoted to internal for test access
- Properties/AssemblyInfo.cs: InternalsVisibleTo(DynamicProxyGenAssembly2)
- ServerTests.cs: 20 new session-10 unit tests (GenerateInfoJson, TlsVersion,
  CopyInfo, GetRandomIP — Test IDs 2895, 2906)

All 565 unit tests + 1 integration test pass.
This commit is contained in:
Joseph Doherty
2026-02-26 15:08:23 -05:00
parent 0df93c23b0
commit 06779a1f77
13 changed files with 2539 additions and 21 deletions

View File

@@ -1077,6 +1077,21 @@ public sealed partial class ClientConnection
// features 425-427: writeLoop / flushClients / readLoop
internal void WriteLoop() { /* TODO session 09 */ }
internal void FlushClients(long budget) { /* TODO session 09 */ }
internal void ReadLoop(byte[]? pre) { /* TODO session 09 */ }
/// <summary>
/// Generates the INFO JSON bytes sent to the client on connect.
/// Stub — full implementation in session 09.
/// Mirrors Go <c>client.generateClientInfoJSON()</c>.
/// </summary>
internal ReadOnlyMemory<byte> GenerateClientInfoJSON(ServerInfo info, bool includeClientIp)
=> ReadOnlyMemory<byte>.Empty;
/// <summary>
/// Sets the auth-timeout timer to the specified duration.
/// Mirrors Go <c>client.setAuthTimer(d)</c>.
/// </summary>
internal void SetAuthTimer(TimeSpan d) { /* TODO session 09 */ }
// features 428-432: closedStateForErr, collapsePtoNB, flushOutbound, handleWriteTimeout, markConnAsClosed
internal static ClosedState ClosedStateForErr(Exception err) =>