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:
@@ -13,6 +13,8 @@
|
||||
//
|
||||
// Adapted from server/auth.go (type definitions) in the NATS server Go source.
|
||||
|
||||
using ZB.MOM.NatsNet.Server;
|
||||
|
||||
namespace ZB.MOM.NatsNet.Server.Auth;
|
||||
|
||||
/// <summary>
|
||||
@@ -170,7 +172,7 @@ public class RoutePermissions
|
||||
/// Stub for Account type. Full implementation in session 11.
|
||||
/// Mirrors Go <c>Account</c> struct.
|
||||
/// </summary>
|
||||
public class Account
|
||||
public class Account : INatsAccount
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
@@ -184,6 +186,27 @@ public class Account
|
||||
internal ZB.MOM.NatsNet.Server.Internal.DataStructures.SubscriptionIndex? Sublist { get; set; }
|
||||
internal object? Server { get; set; } // INatsServer — avoids circular reference
|
||||
|
||||
// INatsAccount — stub implementations until session 11 (accounts.go).
|
||||
bool INatsAccount.IsValid => true;
|
||||
bool INatsAccount.MaxTotalConnectionsReached() => false;
|
||||
bool INatsAccount.MaxTotalLeafNodesReached() => false;
|
||||
int INatsAccount.AddClient(ClientConnection c) => 0;
|
||||
int INatsAccount.RemoveClient(ClientConnection c) => 0;
|
||||
|
||||
/// <summary>Returns true if this account's JWT has expired. Stub — full impl in session 11.</summary>
|
||||
public bool IsExpired() => false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the total number of subscriptions across all clients in this account.
|
||||
/// Stub — full implementation in session 11.
|
||||
/// Mirrors Go <c>Account.TotalSubs()</c>.
|
||||
/// </summary>
|
||||
public int TotalSubs() => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Notifies leaf nodes of a subscription change.
|
||||
/// Stub — full implementation in session 15.
|
||||
/// Mirrors Go <c>Account.updateLeafNodes()</c>.
|
||||
/// </summary>
|
||||
internal void UpdateLeafNodes(object sub, int delta) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user