feat: add NATS / JetStream messaging gateway#4249
Conversation
Code Review — NATS / JetStream messaging gateway (PR #4249)Thanks for this — it's a large, well-documented, and largely well-structured transport. The XML docs are excellent, the licence headers are consistent, and the split between core NATS (at-most-once) and JetStream (at-least-once) semantics is clearly explained. Below is my feedback, ordered by severity. 🔴 Blocking / likely bugs1. var next = _enumerator.MoveNextAsync(); // called unconditionally
if (next.IsCompleted) { return [_enumerator.Current.ToMessage()]; }
_pendingMoveNext ??= next.AsTask(); // old pending kept, `next` discardedThe normal message-pump path calls if (_pendingMoveNext is null)
{
var next = _enumerator.MoveNextAsync();
if (next.IsCompletedSuccessfully)
return next.Result ? [_enumerator.Current.ToMessage()] : [new Message()];
_pendingMoveNext = next.AsTask();
}(Also note This path has no test coverage (see point 5), which is why it wasn't caught. 2. foreach (var keyPair in messageHeader.Baggage) // <-- Baggage, not Bag
{
if (keyPair.Value != null) headers[keyPair.Key] = keyPair.Value;
}Baggage is already serialized above into 🟠 Worth addressing3. JetStream is not enabled in the CI service container. The 4. 5. Test coverage is core-NATS only. 6. Receive-side 🟡 Minor / style
✅ Nice things
Overall the core-NATS path looks solid; the JetStream path needs bug #1 fixed and test coverage before I'd be comfortable merging. Nice work on the docs and structure. 🤖 Automated review — verify findings before acting on them. |
Summary
Adds a NATS transport for Brighter, covering both core NATS and JetStream.
What's included
Paramore.Brighter.MessagingGateway.NATSproject:NatsMessageProducer,NatsMessageConsumer,NatsSubscription,NatsPublication,NatsChannelFactoryNatsStreamMessageProducer,NatsStreamMessageConsumer,NatsStreamSubscription,NatsStreamPublicationNatsMsgExtensions,MessageHeaderExtensions,HeadersName) andNatsNameSanitizerNatsMessageGatewayConfigurationMessagingSystem.NATSentriesParamore.Brighter.NATS.Testsproject (reactor + proactor gateway tests: send/receive, multiple messages, concurrent senders, failed-message redelivery, activity-context propagation)docker-compose-nats.yamlfor local testingnats-cijob running the NATS transport tests against anats:latestservice container