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.
This commit is contained in:
Joseph Doherty
2026-02-26 13:16:56 -05:00
parent 0a54d342ba
commit 88b1391ef0
56 changed files with 9006 additions and 6 deletions

View File

@@ -0,0 +1,49 @@
# Session 08: Client Connection
## Summary
The client connection handler — manages individual client TCP connections, message processing, subscription management, and client lifecycle. The largest single class in the server.
## Scope
| Go File | Features | Feature IDs | Go LOC |
|---------|----------|-------------|--------|
| server/client.go | 185 | 387571 | 5,680 |
| server/client_proxyproto.go | 10 | 572581 | 273 |
| **Total** | **195** | | **5,953** |
## .NET Classes
- `ClientConnection` — client state, read/write loops, publish, subscribe, unsubscribe
- `ClientFlag` — client state flags
- `ClientInfo` — client metadata
- `ProxyProtocolAddress` — PROXY protocol v1/v2 parsing
## Test Files
| Test File | Tests | Test IDs |
|-----------|-------|----------|
| server/client_test.go | 82 | 182263 |
| server/client_proxyproto_test.go | 23 | 159181 |
| server/closed_conns_test.go | 7 | 264270 |
| server/ping_test.go | 1 | 2615 |
| **Total** | **113** | |
## Dependencies
- Session 01 (Foundation Types)
- Session 02 (Utilities — queues)
- Session 03 (Configuration — ServerOptions)
- Session 05 (Subscription Index)
- Session 07 (Protocol Parser)
## .NET Target Location
- `dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.cs`
## Notes
- This is the core networking class — every connected client has one
- Heavy use of `sync.Mutex` in Go → consider `lock` or `SemaphoreSlim`
- Write coalescing and flush logic is performance-critical
- May need partial class split: `ClientConnection.Read.cs`, `ClientConnection.Write.cs`, etc.