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.
53 lines
1.7 KiB
Markdown
53 lines
1.7 KiB
Markdown
# Session 09: Server Core — Initialization & Configuration
|
||
|
||
## Summary
|
||
|
||
First half of server.go: server construction, validation, account configuration, resolver setup, trusted keys, and the `Start()` method. This is the server bootstrap path.
|
||
|
||
## Scope
|
||
|
||
| Go File | Features | Feature IDs | Go LOC |
|
||
|---------|----------|-------------|--------|
|
||
| server/server.go (lines 85–2575) | ~76 | 2974–3050 | ~1,950 |
|
||
| **Total** | **~76** | | **~1,950** |
|
||
|
||
### Key Features
|
||
|
||
- `New`, `NewServer`, `NewServerFromConfig` — constructors
|
||
- `validateOptions`, `validateCluster`, `validatePinnedCerts` — config validation
|
||
- `configureAccounts`, `configureResolver`, `checkResolvePreloads` — account setup
|
||
- `processTrustedKeys`, `initStampedTrustedKeys` — JWT trust chain
|
||
- `Start` — main server startup (313 LOC)
|
||
- Compression helpers (`selectCompressionMode`, `s2WriterOptions`, etc.)
|
||
- Account lookup/register/update methods
|
||
|
||
## .NET Classes
|
||
|
||
- `NatsServer` (partial — initialization, configuration, accounts)
|
||
|
||
## Test Files
|
||
|
||
| Test File | Tests | Test IDs |
|
||
|-----------|-------|----------|
|
||
| server/server_test.go (partial) | ~20 | 2866–2885 |
|
||
| **Total** | **~20** | |
|
||
|
||
## Dependencies
|
||
|
||
- Session 01 (Foundation Types)
|
||
- Session 03 (Configuration — ServerOptions)
|
||
- Session 04 (Logging)
|
||
- Session 05 (Subscription Index)
|
||
- Session 06 (Authentication)
|
||
|
||
## .NET Target Location
|
||
|
||
- `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.cs` (partial class)
|
||
- Consider: `NatsServer.Init.cs`, `NatsServer.Accounts.cs`
|
||
|
||
## Notes
|
||
|
||
- `Server.Start()` is 313 LOC — the single largest function. Port carefully.
|
||
- Account configuration deeply intertwines with JWT and resolver subsystems
|
||
- Many methods reference route, gateway, and leafnode structures (forward declarations needed)
|