[ISSUE #1697]🚀EscapeBridge supports putMessageToRemoteBroker🔥#1708
[ISSUE #1697]🚀EscapeBridge supports putMessageToRemoteBroker🔥#1708rocketmq-rust-bot merged 1 commit intomainfrom
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
🔊@mxsm 🚀Thanks for your contribution 🎉. CodeRabbit(AI) will review your code first 🔥 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1708 +/- ##
==========================================
- Coverage 28.00% 27.96% -0.05%
==========================================
Files 473 473
Lines 63610 63702 +92
==========================================
Hits 17816 17816
- Misses 45794 45886 +92 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (2)
rocketmq-broker/src/failover/escape_bridge.rs (2)
113-121: Simplify condition checks and improve readability.The current condition for checking
broker_name_to_sendand comparing broker names can be simplified to enhance readability and maintainability.Consider refactoring using pattern matching:
if let Some(broker_name) = &broker_name_to_send { if self.broker_config.broker_identity.broker_name == *broker_name { return None; } }
209-216: Consider usingunwrap_orfor cleaner code.In the
get_producer_groupmethod, you can simplify the match statement usingunwrap_orfor better readability.Refactor as:
fn get_producer_group(&self, message_ext: &MessageExtBrokerInner) -> CheetahString { message_ext.get_property(&CheetahString::from_static_str( MessageConst::PROPERTY_PRODUCER_GROUP, )).unwrap_or_else(|| self.inner_producer_group_name.clone()) }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
rocketmq-broker/src/failover/escape_bridge.rs(3 hunks)rocketmq-broker/src/out_api/broker_outer_api.rs(2 hunks)
🔇 Additional comments (2)
rocketmq-broker/src/failover/escape_bridge.rs (2)
87-87: Ensure proper initialization of broker_outer_api.
The new field broker_outer_api added to the EscapeBridge struct must be properly initialized to prevent potential None or uninitialized usage issues. Verify that all constructors or initializations of EscapeBridge include this new field.
190-196: Handle potential errors from send_message_to_specific_broker.
Currently, the code assumes that the send_message_to_specific_broker method will succeed. It's essential to handle potential errors more gracefully.
Ensure that the calling code correctly handles any Err variants returned by this method, possibly by logging or retrying as needed.
| if !topic_publish_info.as_ref().is_some_and(|value| value.ok()) { | ||
| warn!( |
There was a problem hiding this comment.
Avoid using unstable is_some_and method.
The method is_some_and is currently unstable and not available in stable Rust releases. This may lead to compatibility issues.
Refactor the code to use stable alternatives:
if let Some(Ok(_)) = &topic_publish_info {
// Proceed with the logic
} else {
warn!(
"putMessageToRemoteBroker: no route info of topic {} when escaping message, \
msgId={}",
message_to_put.get_topic(),
message_to_put.message_ext_inner.msg_id
);
return None;
}| .is_some_and(|value| !value.is_empty()) | ||
| { |
There was a problem hiding this comment.
Avoid using unstable is_some_and method.
Again, is_some_and is unstable. It's better to use stable features to ensure compatibility.
Refactor the condition as follows:
let mq_selected = if let Some(broker_name) = &broker_name_to_send {
if !broker_name.is_empty() {
// Proceed with selecting the message queue
} else {
// Handle the else case
}
} else {
// Handle the None case
};| let broker_addr_to_send = self | ||
| .topic_route_info_manager | ||
| .find_broker_address_in_publish(broker_name_to_send.as_ref()); |
There was a problem hiding this comment.
Check for None before unwrapping broker_name_to_send.
Ensure that broker_name_to_send is not None before calling as_ref().unwrap() to avoid potential panics.
Add a check or use pattern matching:
let broker_addr_to_send = if let Some(broker_name) = &broker_name_to_send {
self
.topic_route_info_manager
.find_broker_address_in_publish(Some(broker_name))
} else {
// Handle the None case appropriately
};| pub async fn send_message_to_specific_broker( | ||
| &self, | ||
| _broker_addr: &CheetahString, | ||
| _msg: MessageExt, | ||
| _group: CheetahString, | ||
| _timeout_millis: u64, | ||
| ) -> Result<SendResult> { | ||
| unimplemented!("sendMessageToSpecificBroker") | ||
| } |
There was a problem hiding this comment.
Implement send_message_to_specific_broker or handle its unavailability.
The method send_message_to_specific_broker is currently unimplemented, which may cause runtime panics if called. This could lead to unexpected behavior in production.
Consider providing an implementation for this method or, if it's intended for future use, ensure that calling code checks for its availability before invoking it. Would you like assistance in implementing this method or creating a safe stub?
Which Issue(s) This PR Fixes(Closes)
Fixes #1697
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
EscapeBridge.BrokerOuterAPI.Bug Fixes
Documentation