[ISSUE #6502]♻️Refactor transaction listener usage to utilize ArcTransactionListener for improved type safety and clarity#6503
Conversation
…sactionListener for improved type safety and clarity
|
🔊@mxsm 🚀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 pull request refactors transaction listener handling by introducing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
🧹 Nitpick comments (1)
rocketmq-client/src/producer/transaction_mq_produce_builder.rs (1)
338-342: Consider clamping/validating min/max check thread-pool sizesCurrently any values (including 0 or min > max) are accepted. Normalizing in
buildavoids invalid configs.♻️ Possible normalization in build
- let transaction_producer_config = TransactionProducerConfig { - transaction_listener: self.transaction_listener, - check_thread_pool_min_size: self.check_thread_pool_min_size.unwrap_or(1), - check_thread_pool_max_size: self.check_thread_pool_max_size.unwrap_or(1), - check_request_hold_max: self.check_request_hold_max.unwrap_or(2000), - }; + let min_pool = self.check_thread_pool_min_size.unwrap_or(1).max(1); + let max_pool = self.check_thread_pool_max_size.unwrap_or(min_pool).max(min_pool); + let transaction_producer_config = TransactionProducerConfig { + transaction_listener: self.transaction_listener, + check_thread_pool_min_size: min_pool, + check_thread_pool_max_size: max_pool, + check_request_hold_max: self.check_request_hold_max.unwrap_or(2000), + };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rocketmq-client/src/producer/transaction_mq_produce_builder.rs` around lines 338 - 342, The TransactionProducerConfig currently accepts any values for check_thread_pool_min_size and check_thread_pool_max_size (including 0 or min>max); update the builder's build method to validate and normalize these fields before constructing TransactionProducerConfig: ensure check_thread_pool_min_size is at least 1, ensure check_thread_pool_max_size is at least check_thread_pool_min_size (or if max < min, set max = min), and clamp both to sensible upper limits if desired (e.g., a safe constant) and also validate check_request_hold_max (e.g., positive, default to 2000); perform these adjustments where the TransactionProducerConfig is created so invalid configs are never produced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rocketmq-client/src/producer/transaction_mq_produce_builder.rs`:
- Around line 338-342: The TransactionProducerConfig currently accepts any
values for check_thread_pool_min_size and check_thread_pool_max_size (including
0 or min>max); update the builder's build method to validate and normalize these
fields before constructing TransactionProducerConfig: ensure
check_thread_pool_min_size is at least 1, ensure check_thread_pool_max_size is
at least check_thread_pool_min_size (or if max < min, set max = min), and clamp
both to sensible upper limits if desired (e.g., a safe constant) and also
validate check_request_hold_max (e.g., positive, default to 2000); perform these
adjustments where the TransactionProducerConfig is created so invalid configs
are never produced.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
rocketmq-client/src/producer/producer_impl/default_mq_producer_impl.rsrocketmq-client/src/producer/producer_impl/mq_producer_inner.rsrocketmq-client/src/producer/transaction_listener.rsrocketmq-client/src/producer/transaction_mq_produce_builder.rsrocketmq-client/src/producer/transaction_mq_producer.rsrocketmq-client/tests/transaction_producer_test.rs
rocketmq-rust-bot
left a comment
There was a problem hiding this comment.
LGTM - All CI checks passed ✅
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6503 +/- ##
==========================================
+ Coverage 42.18% 42.26% +0.07%
==========================================
Files 942 942
Lines 131785 131811 +26
==========================================
+ Hits 55595 55707 +112
+ Misses 76190 76104 -86 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes(Closes)
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
Improvements
Tests