Files
natsnet/docs/plans/phases/phase6sessions/session-21.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

2.3 KiB
Raw Blame History

Session 21: Streams & Consumers

Summary

Stream and consumer implementations — the core JetStream data plane. Streams store messages; consumers track delivery state and manage acknowledgments.

Scope

Go File Features Feature IDs Go LOC
server/stream.go 193 31953387 6,980
server/consumer.go 209 584792 5,720
Total 402 12,700

.NET Classes

  • NatsStream — stream lifecycle, message ingestion, purge, snapshots (193 features)
  • NatsConsumer — consumer lifecycle, delivery, ack, nak, redelivery (174 features)
  • ConsumerAction, ConsumerConfig, AckPolicy, DeliverPolicy, ReplayPolicy — consumer types
  • StreamConfig, StreamSource, ExternalStream — stream types
  • PriorityPolicy, RetentionPolicy, DiscardPolicy, PersistModeType — policy enums
  • WaitQueue, WaitingRequest, WaitingDelivery — consumer wait types
  • JSPubAckResponse, PubMsg, JsPubMsg, InMsg, CMsg — message types

Test Files

Test File Tests Test IDs
server/jetstream_consumer_test.go 161 12201380
server/jetstream_leafnode_test.go 13 14031415
server/norace_1_test.go 100 23712470
server/norace_2_test.go 41 24712511
Total 315

Dependencies

  • Session 01 (Foundation Types)
  • Session 02 (Utilities)
  • 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/JetStream/

Notes

  • This is a multi-sitting session — 12.7K Go LOC and 315 tests
  • Suggested sub-batching:
    • 21a: Stream/consumer types and enums (~40 features, ~500 LOC)
    • 21b: NatsStream core (create, delete, purge — ~95 features)
    • 21c: NatsStream remaining (snapshots, sources, mirrors — ~98 features)
    • 21d: NatsConsumer core (create, deliver, ack — ~90 features)
    • 21e: NatsConsumer remaining (redelivery, pull, push — ~84 features)
    • 21f: Tests (315 tests)
  • norace_*_test.go files contain tests that must run without the Go race detector — these may have concurrency timing sensitivities
  • Consumer pull/push patterns need careful async design in C#