feat: infer and harden bus consumer topology - #77
Conversation
Adds Service::named-derived consumer groups, awaitable bus constructors, shared topology validation, and inferred-group transport coverage. Implements [[tasks/infer-bus-topology-from-service-name]] and [[tasks/harden-inferred-bus-topology]].
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR establishes stable consumer identity and topology scoping for distributed message buses by introducing Service::named() for services and extending MessageRouter::consumer_group() for routers, refactoring transport adapters to fluent builders (e.g., KafkaBus::connect(brokers).group(...).namespace(...)), and centralizing topology validation/resolution in BusTopologyConfig. ChangesConsumer Identity, Topology Validation, and Transport Builder Refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/bus/handlers.rs (1)
80-86: ⚡ Quick winAdd a direct unit test for
Handlers::namedidentity exposure.This new contract is central to inferred group resolution, but there’s no local test asserting
named(..)flows throughMessageRouter::consumer_group().Proposed test addition
#[cfg(test)] mod tests { use super::*; @@ + #[test] + fn named_handlers_expose_consumer_group() { + let handlers = Handlers::new().named("order-projection"); + assert_eq!( + crate::bus::MessageRouter::consumer_group(&handlers), + Some("order-projection") + ); + } + #[test] fn subscription_plan_groups_by_kind() {Also applies to: 115-117
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/bus/handlers.rs` around lines 80 - 86, Add a focused unit test that constructs a Handlers instance, calls Handlers::named("some-group"), wires it through whatever builder/registration path you have so it produces a MessageRouter (or obtains the router via the same factory used in production), then assert that MessageRouter::consumer_group() returns "some-group"; specifically reference Handlers::named and MessageRouter::consumer_group() in the test to ensure the named identity flows through the registry/listen/subscribe path unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/bus/handlers.rs`:
- Around line 80-86: Add a focused unit test that constructs a Handlers
instance, calls Handlers::named("some-group"), wires it through whatever
builder/registration path you have so it produces a MessageRouter (or obtains
the router via the same factory used in production), then assert that
MessageRouter::consumer_group() returns "some-group"; specifically reference
Handlers::named and MessageRouter::consumer_group() in the test to ensure the
named identity flows through the registry/listen/subscribe path unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b98a9adb-3a4e-47a5-b5b7-205e4531b455
📒 Files selected for processing (19)
README.mddocs/async-transports.mdsrc/bus/bus.rssrc/bus/handlers.rssrc/bus/kafka_bus.rssrc/bus/mod.rssrc/bus/nats_bus.rssrc/bus/postgres_bus.rssrc/bus/rabbit_bus.rssrc/bus/router.rssrc/bus/topology.rssrc/lock/async_in_memory.rssrc/microsvc/message_router.rssrc/microsvc/service.rstests/distributed_read_model/main.rstests/kafka_transport/main.rstests/nats_transport/main.rstests/postgres_transport/main.rstests/rabbitmq_transport/main.rs
Addresses CodeRabbit review on [[tasks/address-coderabbit-inferred-bus-topology]].
| } | ||
|
|
||
| #[test] | ||
| fn named_handlers_expose_consumer_group() { |
There was a problem hiding this comment.
Addressed in be3d94a: added named_handlers_expose_consumer_group, which constructs Handlers::new().named("order-projection") and asserts that MessageRouter::consumer_group() exposes the same identity.
Adds Service::named-derived consumer groups, awaitable bus constructors, shared topology validation, and inferred-group transport coverage.
Implements [[tasks/infer-bus-topology-from-service-name]] and [[tasks/harden-inferred-bus-topology]].
Summary by CodeRabbit
New Features
Documentation
Tests