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.
52 lines
1.6 KiB
Markdown
52 lines
1.6 KiB
Markdown
# Session 22: MQTT
|
||
|
||
## Summary
|
||
|
||
MQTT 3.1.1/5.0 protocol adapter — allows MQTT clients to connect to NATS and interact with JetStream for persistence.
|
||
|
||
## Scope
|
||
|
||
| Go File | Features | Feature IDs | Go LOC |
|
||
|---------|----------|-------------|--------|
|
||
| server/mqtt.go | 153 | 2252–2404 | 4,758 |
|
||
| **Total** | **153** | | **4,758** |
|
||
|
||
## .NET Classes
|
||
|
||
- `MqttHandler` — MQTT protocol handler (35 features)
|
||
- `MqttAccountSessionManager` — per-account MQTT session tracking (26 features)
|
||
- `MqttSession` — individual MQTT session state (15 features)
|
||
- `MqttJetStreamAdapter` — bridges MQTT to JetStream (22 features)
|
||
- `MqttReader` — MQTT packet reader (8 features)
|
||
- `MqttWriter` — MQTT packet writer (5 features)
|
||
- Various MQTT reload options
|
||
|
||
## Test Files
|
||
|
||
| Test File | Tests | Test IDs |
|
||
|-----------|-------|----------|
|
||
| server/mqtt_test.go | 159 | 2170–2328 |
|
||
| server/mqtt_ex_test_test.go | 2 | 2168–2169 |
|
||
| server/mqtt_ex_bench_test.go | 1 | 2167 |
|
||
| **Total** | **162** | |
|
||
|
||
## Dependencies
|
||
|
||
- Session 01 (Foundation Types)
|
||
- Session 08 (Client Connection)
|
||
- Session 09 (Server Core Part 1)
|
||
- Session 11 (Accounts)
|
||
- Session 17 (Store Interfaces)
|
||
- Session 19 (JetStream Core)
|
||
|
||
## .NET Target Location
|
||
|
||
- `dotnet/src/ZB.MOM.NatsNet.Server/Mqtt/`
|
||
|
||
## Notes
|
||
|
||
- MQTT is a self-contained protocol layer — could potentially be a separate assembly
|
||
- 159 MQTT tests cover connection, subscribe, publish, QoS levels, sessions, retained messages
|
||
- MQTT ↔ JetStream bridging is the most complex part
|
||
- Consider using `System.IO.Pipelines` for MQTT packet parsing
|