-
Notifications
You must be signed in to change notification settings - Fork 218
[ISSUE #4858]♻️Refactor send_batch_to_queue_with_timeout to accept generic message types implementing MessageTrait #4978
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
…t generic message types implementing MessageTrait
|
🔊@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💥. |
WalkthroughThe 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
🧪 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the send_batch_to_queue_with_timeout method to accept generic message types implementing MessageTrait instead of only accepting the concrete Message type. This change aligns with the existing pattern used by other send methods in the MQProducer trait and provides greater flexibility for users.
Key Changes
- Introduced generic type parameter
Mwith boundsMessageTrait + Send + Syncto thesend_batch_to_queue_with_timeoutmethod - Updated both trait definition and implementations in
DefaultMQProducerandTransactionMQProducer
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| rocketmq-client/src/producer/mq_producer.rs | Updated trait definition to make send_batch_to_queue_with_timeout generic over message types |
| rocketmq-client/src/producer/default_mq_producer.rs | Updated implementation to support generic message types with MessageTrait bounds |
| rocketmq-client/src/producer/transaction_mq_producer.rs | Updated delegating implementation to support generic message types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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: 0
🧹 Nitpick comments (2)
rocketmq-client/src/producer/mq_producer.rs (2)
517-536: Update documentation to include the type parameter.The method documentation (lines 517-528) should be updated to document the newly added generic type parameter
Mand its trait bounds, similar to other generic methods in this trait (e.g.,send_batchat lines 469-481).🔎 Proposed documentation update
/// Sends a batch of messages to a specific message queue with a timeout. /// +/// # Type Parameters +/// +/// * `M` - A type that implements `MessageTrait`, `Send`, and `Sync`. +/// /// # Arguments /// /// * `msgs` - A vector of messages to be sent.
494-616: Consider making all batch methods generic for API consistency.The
send_batch_to_queue_with_timeoutmethod is now generic overM: MessageTrait + Send + Sync, while other batch methods (send_batch_with_timeout,send_batch_to_queue,send_batch_with_callback,send_batch_with_callback_timeout,send_batch_to_queue_with_callback, andsend_batch_to_queue_with_callback_timeout) still use concreteVec<Message>parameters. This creates an inconsistency in the API surface.If the goal is to support generic message types across batch operations, consider making these methods generic as well. If there's a specific reason only
send_batch_to_queue_with_timeoutneeds genericity, documenting that rationale would help future maintainers.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
rocketmq-client/src/producer/default_mq_producer.rsrocketmq-client/src/producer/mq_producer.rsrocketmq-client/src/producer/transaction_mq_producer.rs
🧰 Additional context used
🧬 Code graph analysis (2)
rocketmq-client/src/producer/default_mq_producer.rs (2)
rocketmq-client/src/producer/mq_producer.rs (1)
send_batch_to_queue_with_timeout(529-536)rocketmq-client/src/producer/transaction_mq_producer.rs (1)
send_batch_to_queue_with_timeout(379-391)
rocketmq-client/src/producer/mq_producer.rs (3)
rocketmq-client/src/producer/default_mq_producer.rs (1)
send_batch_to_queue_with_timeout(1083-1100)rocketmq-client/src/producer/transaction_mq_producer.rs (1)
send_batch_to_queue_with_timeout(379-391)rocketmq-client/src/hook/filter_message_context.rs (1)
mq(57-59)
⏰ 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). (6)
- GitHub Check: Build & Test (windows-latest)
- GitHub Check: Build & Test (ubuntu-latest)
- GitHub Check: Build & Test (macos-latest)
- GitHub Check: Code Coverage
- GitHub Check: Agent
- GitHub Check: auto-approve
🔇 Additional comments (2)
rocketmq-client/src/producer/transaction_mq_producer.rs (1)
379-391: LGTM!The implementation correctly updates the method signature to be generic over
M: MessageTrait + Send + Syncand properly delegates to the underlyingdefault_producer.rocketmq-client/src/producer/default_mq_producer.rs (1)
1083-1100: LGTM!The implementation correctly updates the method signature to be generic over
M: MessageTrait + Send + Sync. The internalbatchmethod (line 1092) already supports generic message types, so this change integrates seamlessly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4978 +/- ##
=======================================
Coverage 33.34% 33.34%
=======================================
Files 742 742
Lines 108282 108288 +6
=======================================
+ Hits 36103 36106 +3
- Misses 72179 72182 +3 ☔ 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 ✅
mxsm
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
Which Issue(s) This PR Fixes(Closes)
Fixes #4858
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.