-
Notifications
You must be signed in to change notification settings - Fork 218
[ISSUE #5173]✨Add error handlingor uninitialized DefaultMQProducer in send_with_selector #5396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…r in send_with_selector
|
🔊@WaterWhisperer 🚀Thanks for your contribution🎉! 💡CodeRabbit(AI) will review your code first🔥! Note 🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥. |
WalkthroughThis PR replaces two Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
rocketmq-client/src/producer/default_mq_producer.rs (2)
1203-1231: Add test coverage for the changed method.The test validates error handling for
request_with_callback, but doesn't cover the specific method changed in this PR (send_with_selector). Consider adding a test that callssend_with_selectoron an uninitialized producer to verify the fix.🔎 Suggested test
#[tokio::test] async fn send_with_selector_not_initialized() { // Arrange let mut producer = DefaultMQProducer { client_config: Default::default(), producer_config: Default::default(), default_mqproducer_impl: None, }; let msg = Message { topic: "test-topic".into(), flag: 0, properties: Default::default(), body: None, compressed_body: None, transaction_id: None, }; let selector = |_queues: &[MessageQueue], _msg: &dyn MessageTrait, _arg: &dyn std::any::Any| None; // Act let result = producer.send_with_selector(msg, selector, ()).await; // Assert assert!(result.is_err()); let err = result.unwrap_err(); match err { RocketMQError::NotInitialized(reason) => { assert!(reason.contains("not initialized"), "unexpected error message: {reason}"); } other => panic!("Unexpected error: {other:?}"), } }
1106-1106: Minor inconsistency in error message.The error message here uses "DefaultMQProducerImpl is not initialized" while most other locations (including the newly changed line 820) use "DefaultMQProducerImpl not initialized" (without "is"). Consider standardizing for consistency.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-client/src/producer/default_mq_producer.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-10T06:20:00.401Z
Learnt from: 578223592
Repo: mxsm/rocketmq-rust PR: 3240
File: rocketmq-namesrv/src/kvconfig/kvconfig_mananger.rs:69-71
Timestamp: 2025-05-10T06:20:00.401Z
Learning: In RocketMQ Rust, while dashmap is concurrent-safe, returning a direct reference to a DashMap can break encapsulation by allowing external code to modify the map without triggering persistence methods like `persist()`. Consider returning a read-only view, iterator methods, or a snapshot instead.
Applied to files:
rocketmq-client/src/producer/default_mq_producer.rs
🧬 Code graph analysis (1)
rocketmq-client/src/producer/default_mq_producer.rs (1)
rocketmq-error/src/unified.rs (1)
not_initialized(521-523)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Check (fmt + clippy)
- GitHub Check: auto-approve
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5396 +/- ##
=======================================
Coverage 37.26% 37.26%
=======================================
Files 803 803
Lines 108756 108755 -1
=======================================
+ Hits 40523 40526 +3
+ Misses 68233 68229 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rocketmq-rust-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - All CI checks passed ✅
Which Issue(s) This PR Fixes(Closes)
Fixes #5173
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.