-
Notifications
You must be signed in to change notification settings - Fork 216
[ISSUE #4857]♻️Refactor send_batch_to_queue to accept generic messagetypes implementing MessageTrait #4977
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
…sage 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 method to accept generic message types implementing MessageTrait instead of being restricted to the concrete Message type. This change enhances flexibility by allowing the method to work with any type that implements the MessageTrait trait.
Key Changes:
- Added generic type parameter
Mwith trait boundsMessageTrait + Send + Synctosend_batch_to_queue - Updated the trait definition in
MQProducerand implementations inDefaultMQProducerandTransactionMQProducer
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rocketmq-client/src/producer/mq_producer.rs | Updated trait method signature to accept generic message type |
| rocketmq-client/src/producer/default_mq_producer.rs | Updated implementation to use generic message type parameter |
| rocketmq-client/src/producer/transaction_mq_producer.rs | Updated delegating implementation to use generic message type parameter |
💡 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 (1)
rocketmq-client/src/producer/mq_producer.rs (1)
511-517: Consider genericizing related batch methods for API consistency.The refactor successfully makes
send_batch_to_queuegeneric, but several related methods remain concrete:
send_batch_to_queue_with_timeout(line 531)send_batch_to_queue_with_callback(line 587)send_batch_to_queue_with_callback_timeout(line 608)This creates an inconsistent API where users can send generic message batches to a queue, but only if they don't need timeouts or callbacks. Consider applying the same genericization to these related methods for a uniform developer experience.
Note on existing inconsistency
A similar pattern already exists:
send_batch(line 479) is generic butsend_batch_with_timeout(line 494) is not. Addressing all batch methods together would resolve both inconsistencies.
📜 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 (3)
rocketmq-client/src/producer/default_mq_producer.rs (2)
rocketmq-client/src/producer/mq_producer.rs (1)
send_batch_to_queue(511-517)rocketmq-client/src/producer/transaction_mq_producer.rs (1)
send_batch_to_queue(371-380)
rocketmq-client/src/producer/transaction_mq_producer.rs (2)
rocketmq-client/src/producer/default_mq_producer.rs (1)
send_batch_to_queue(1068-1084)rocketmq-client/src/producer/mq_producer.rs (1)
send_batch_to_queue(511-517)
rocketmq-client/src/producer/mq_producer.rs (2)
rocketmq-client/src/producer/default_mq_producer.rs (1)
send_batch_to_queue(1068-1084)rocketmq-client/src/producer/transaction_mq_producer.rs (1)
send_batch_to_queue(371-380)
⏰ 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
🔇 Additional comments (2)
rocketmq-client/src/producer/default_mq_producer.rs (1)
1068-1084: Implementation correctly delegates to generic batch helper.The genericization is properly implemented by leveraging the existing
batchmethod (lines 474-495), which already acceptsVec<M>whereM: MessageTrait. The flow is clean: batch the messages, then send viasync_send_with_message_queue.rocketmq-client/src/producer/transaction_mq_producer.rs (1)
371-380: Clean delegation to the underlying producer.The implementation correctly forwards the generic message batch to
default_producer.send_batch_to_queue, maintaining the simple delegation pattern used throughoutTransactionMQProducer.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4977 +/- ##
=======================================
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 #4857
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.