-
Notifications
You must be signed in to change notification settings - Fork 189
[ISSUE #4856]♻️Refactor send_batch_with_timeout to accept generic message types implementing MessageTrait #4976
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
base: main
Are you sure you want to change the base?
Conversation
… 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) | ⏱️ ~10 minutes 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_with_timeout method to accept generic message types implementing MessageTrait, improving API flexibility and consistency with the existing send_batch method.
Key Changes
- Modified the
send_batch_with_timeoutmethod signature in theMQProducertrait to accept generic typeM: MessageTrait + Send + Syncinstead of concreteVec<Message> - Updated both implementations (
DefaultMQProducerandTransactionMQProducer) to use the generic type parameter - Changes maintain backward compatibility while enabling more flexible message type usage
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rocketmq-client/src/producer/mq_producer.rs | Updated trait method signature to accept generic message type with appropriate trait bounds |
| rocketmq-client/src/producer/default_mq_producer.rs | Updated implementation to use generic type parameter, leveraging the existing generic batch method |
| rocketmq-client/src/producer/transaction_mq_producer.rs | Updated implementation to forward generic type parameter to the delegated default_producer call |
💡 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 (3)
rocketmq-client/src/producer/transaction_mq_producer.rs (1)
361-372: Refactoring successfully applied.The generic signature correctly matches the trait definition and delegates properly to
default_producer. However, the refactoring is incomplete—other batch methods likesend_batch_to_queue,send_batch_with_callback, etc. (lines 374-447) still use the concreteVec<Message>type. Consider generalizing them as well for API consistency.Methods that could be generalized for consistency
send_batch_to_queue(line 374)send_batch_to_queue_with_timeout(line 382)send_batch_with_callback(line 393)send_batch_with_callback_timeout(line 406)send_batch_to_queue_with_callback(line 420)send_batch_to_queue_with_callback_timeout(line 434)rocketmq-client/src/producer/mq_producer.rs (1)
494-500: Trait signature correctly updated.The generic signature aligns with the PR objective and is properly bounded. However, this creates an inconsistency within the
MQProducertrait—send_batch(line 479) andsend_batch_with_timeoutare now generic, while the remaining batch methods (lines 513-616) still requireVec<Message>. Consider extending the refactoring to all batch operations for a uniform API surface.rocketmq-client/src/producer/default_mq_producer.rs (1)
1053-1069: Implementation correctly handles the generic type.The method properly delegates to the existing
batch()helper (line 474), which already accepts genericVec<M>. The logic is sound and consistent with the trait definition. As with the other files, consider generalizing the remaining batch methods (lines 1071-1170) to maintain API consistency across the producer interface.
📜 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/mq_producer.rs (2)
rocketmq-client/src/producer/default_mq_producer.rs (1)
send_batch_with_timeout(1053-1069)rocketmq-client/src/producer/transaction_mq_producer.rs (1)
send_batch_with_timeout(361-372)
rocketmq-client/src/producer/default_mq_producer.rs (2)
rocketmq-client/src/producer/mq_producer.rs (1)
send_batch_with_timeout(494-500)rocketmq-client/src/producer/transaction_mq_producer.rs (1)
send_batch_with_timeout(361-372)
⏰ 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 (macos-latest)
- GitHub Check: Build & Test (ubuntu-latest)
- GitHub Check: Build & Test (windows-latest)
- GitHub Check: Code Coverage
- GitHub Check: Agent
- GitHub Check: auto-approve
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4976 +/- ##
=======================================
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 ✅
Which Issue(s) This PR Fixes(Closes)
Fixes #4856
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.