Files
natsnet/docs/plans/phases/phase6sessions/session-10.md
Joseph Doherty 88b1391ef0 feat: port session 07 — Protocol Parser, Auth extras (TPM/certidp/certstore), Internal utilities & data structures
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.
2026-02-26 13:16:56 -05:00

58 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 25774782) | ~98 | 30513147 | ~1,881 |
| **Total** | **~98** | | **~1,881** |
### Key Features
- `Shutdown` — graceful shutdown (172 LOC)
- `AcceptLoop`, `acceptConnections` — TCP listener
- `createClientEx` — client connection factory (305 LOC)
- `startMonitoring`, `StartHTTPMonitoring` — HTTP monitoring server
- `lameDuckMode`, `sendLDMToRoutes`, `sendLDMToClients` — lame duck
- `readyForConnections`, `readyForListeners` — startup synchronization
- Numerous `Num*` query methods (routes, clients, subscriptions, etc.)
- `getConnectURLs`, `PortsInfo` — connection metadata
- `removeClient`, `saveClosedClient` — client lifecycle
## .NET Classes
- `NatsServer` (partial — runtime, lifecycle, queries)
- `CaptureHTTPServerLog` — HTTP log adapter
- `TlsMixConn` — mixed TLS/plain connection
## Test Files
| Test File | Tests | Test IDs |
|-----------|-------|----------|
| server/server_test.go (partial) | ~22 | 28862907 |
| server/benchmark_publish_test.go | 1 | 154 |
| server/core_benchmarks_test.go | 4 | 274277 |
| **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
- `createClientEx` is 305 LOC — second largest function in the file
- `Shutdown` involves coordinating across all subsystems
- Monitoring HTTP server maps to ASP.NET Core Kestrel or minimal API
- Lame duck mode requires careful timer/signal coordination