Session 07 scope (5 features, 17 tests, ~1165 Go LOC): - Protocol/ParserTypes.cs: ParserState enum (79 states), PublishArgument, ParseContext - Protocol/IProtocolHandler.cs: handler interface decoupling parser from client - Protocol/ProtocolParser.cs: Parse(), ProtoSnippet(), OverMaxControlLineLimit(), ProcessPub/HeaderPub/RoutedMsgArgs/RoutedHeaderMsgArgs, ClonePubArg(), GetHeader() - tests/Protocol/ProtocolParserTests.cs: 17 tests via TestProtocolHandler stub Auth extras from session 06 (committed separately): - Auth/TpmKeyProvider.cs, Auth/CertificateIdentityProvider/, Auth/CertificateStore/ Internal utilities & data structures (session 06 overflow): - Internal/AccessTimeService.cs, ElasticPointer.cs, SystemMemory.cs, ProcessStatsProvider.cs - Internal/DataStructures/GenericSublist.cs, HashWheel.cs - Internal/DataStructures/SubjectTree.cs, SubjectTreeNode.cs, SubjectTreeParts.cs All 461 tests pass (460 unit + 1 integration). DB updated for features 2588-2592 and tests 2598-2614.
1.9 KiB
1.9 KiB
Session 10: Server Core — Runtime & Lifecycle
Summary
Second half of server.go: accept loops, client creation, monitoring HTTP server, TLS handling, lame duck mode, shutdown, and runtime query methods.
Scope
| Go File | Features | Feature IDs | Go LOC |
|---|---|---|---|
| server/server.go (lines 2577–4782) | ~98 | 3051–3147 | ~1,881 |
| Total | ~98 | ~1,881 |
Key Features
Shutdown— graceful shutdown (172 LOC)AcceptLoop,acceptConnections— TCP listenercreateClientEx— client connection factory (305 LOC)startMonitoring,StartHTTPMonitoring— HTTP monitoring serverlameDuckMode,sendLDMToRoutes,sendLDMToClients— lame duckreadyForConnections,readyForListeners— startup synchronization- Numerous
Num*query methods (routes, clients, subscriptions, etc.) getConnectURLs,PortsInfo— connection metadataremoveClient,saveClosedClient— client lifecycle
.NET Classes
NatsServer(partial — runtime, lifecycle, queries)CaptureHTTPServerLog— HTTP log adapterTlsMixConn— mixed TLS/plain connection
Test Files
| Test File | Tests | Test IDs |
|---|---|---|
| server/server_test.go (partial) | ~22 | 2886–2907 |
| server/benchmark_publish_test.go | 1 | 154 |
| server/core_benchmarks_test.go | 4 | 274–277 |
| Total | ~27 |
Dependencies
- Session 09 (Server Core Part 1)
- Session 08 (Client Connection)
- Session 04 (Logging)
.NET Target Location
dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.cs(partial class)- Consider:
NatsServer.Lifecycle.cs,NatsServer.Listeners.cs
Notes
createClientExis 305 LOC — second largest function in the fileShutdowninvolves coordinating across all subsystems- Monitoring HTTP server maps to ASP.NET Core Kestrel or minimal API
- Lame duck mode requires careful timer/signal coordination