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.1 KiB
1.1 KiB
Session 07: Protocol Parser
Summary
The NATS protocol parser — parses raw bytes from client connections into protocol operations (PUB, SUB, UNSUB, CONNECT, etc.). Extremely performance-critical.
Scope
| Go File | Features | Feature IDs | Go LOC |
|---|---|---|---|
| server/parser.go | 5 | 2588–2592 | 1,165 |
| Total | 5 | 1,165 |
.NET Classes
ProtocolParser— state-machine parser for NATS wire protocolClientConnection(partial — parser-related methods only)
Test Files
| Test File | Tests | Test IDs |
|---|---|---|
| server/parser_test.go | 17 | 2598–2614 |
| Total | 17 |
Dependencies
- Session 01 (Foundation Types — protocol constants, errors)
.NET Target Location
dotnet/src/ZB.MOM.NatsNet.Server/Protocol/
Notes
- Only 5 features but 1,165 LOC — these are large state-machine functions
- Must use
ReadOnlySpan<byte>and avoid allocations in the parse loop - The parser is called for every byte received — benchmark after porting
- Consider using
System.IO.Pipelinesfor buffer management