-
Notifications
You must be signed in to change notification settings - Fork 218
[ISSUE #5538] - Implement ControllerElectMaster Request Handler #5564
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
|
🔊@aditya-rajpurohit 🚀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🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @rocketmq-controller/src/processor/controller_request_processor.rs:
- Around line 317-322: The parameter named `_request` is actually used (see
`_request.decode_command_custom_header::<ElectMasterRequestHeader>()`), so
rename the function parameter from `_request` to `request` in the function
signature and update all usages (e.g., change
`_request.decode_command_custom_header` to
`request.decode_command_custom_header`) to follow Rust naming conventions and
avoid the unused-underscore meaning; ensure any pattern matches, references, and
documentation/comments in that function are updated accordingly.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-controller/src/processor/controller_request_processor.rs
🧰 Additional context used
🧬 Code graph analysis (1)
rocketmq-controller/src/processor/controller_request_processor.rs (4)
rocketmq-remoting/src/protocol/remoting_command.rs (1)
request_code(710-712)rocketmq-controller/src/heartbeat/broker_live_info.rs (1)
channel(108-110)rocketmq-controller/src/controller/controller_manager.rs (1)
controller(620-622)rocketmq-error/src/unified.rs (1)
request_header_error(471-473)
⏰ 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-controller/src/processor/controller_request_processor.rs (2)
91-91: LGTM! Necessary imports added.The imports for
RocketMQErrorandElectMasterRequestHeaderare correctly added and used in thehandle_elect_masterimplementation.Also applies to: 96-96
324-332: Implementation follows the correct pattern.The forwarding to the controller and response handling are implemented correctly. The async
elect_mastermethod with signatureasync fn elect_master(&self, request: &ElectMasterRequestHeader) -> RocketMQResult<Option<RemotingCommand>>is properly called, awaited, and the result is correctly propagated using the?operator before being wrapped inOk()for return.
| // Decode request header | ||
| let request_header = _request | ||
| .decode_command_custom_header::<ElectMasterRequestHeader>() | ||
| .map_err(|e| { | ||
| RocketMQError::request_header_error(format!("Failed to decode ElectMasterRequestHeader: {:?}", e)) | ||
| })?; |
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.
Fix parameter naming: remove underscore prefix from used parameter.
The _request parameter is actually used (lines 318-319), so the underscore prefix violates Rust's naming convention. In Rust, the underscore prefix signals that a parameter is intentionally unused to suppress compiler warnings. Since _request is used here, it should be renamed to request.
🔧 Proposed fix
async fn handle_elect_master(
&mut self,
_channel: Channel,
_ctx: ConnectionHandlerContext,
- _request: &mut RemotingCommand,
+ request: &mut RemotingCommand,
) -> RocketMQResult<Option<RemotingCommand>> {
// Decode request header
- let request_header = _request
+ let request_header = request
.decode_command_custom_header::<ElectMasterRequestHeader>()
.map_err(|e| {
RocketMQError::request_header_error(format!("Failed to decode ElectMasterRequestHeader: {:?}", e))
})?;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Decode request header | |
| let request_header = _request | |
| .decode_command_custom_header::<ElectMasterRequestHeader>() | |
| .map_err(|e| { | |
| RocketMQError::request_header_error(format!("Failed to decode ElectMasterRequestHeader: {:?}", e)) | |
| })?; | |
| async fn handle_elect_master( | |
| &mut self, | |
| _channel: Channel, | |
| _ctx: ConnectionHandlerContext, | |
| request: &mut RemotingCommand, | |
| ) -> RocketMQResult<Option<RemotingCommand>> { | |
| // Decode request header | |
| let request_header = request | |
| .decode_command_custom_header::<ElectMasterRequestHeader>() | |
| .map_err(|e| { | |
| RocketMQError::request_header_error(format!("Failed to decode ElectMasterRequestHeader: {:?}", e)) | |
| })?; |
🤖 Prompt for AI Agents
In @rocketmq-controller/src/processor/controller_request_processor.rs around
lines 317 - 322, The parameter named `_request` is actually used (see
`_request.decode_command_custom_header::<ElectMasterRequestHeader>()`), so
rename the function parameter from `_request` to `request` in the function
signature and update all usages (e.g., change
`_request.decode_command_custom_header` to
`request.decode_command_custom_header`) to follow Rust naming conventions and
avoid the unused-underscore meaning; ensure any pattern matches, references, and
documentation/comments in that function are updated accordingly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5564 +/- ##
==========================================
- Coverage 38.54% 38.51% -0.03%
==========================================
Files 816 816
Lines 110917 110928 +11
==========================================
- Hits 42748 42728 -20
- Misses 68169 68200 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes(Closes)
Fixes #5538
Brief Description
This PR implements handling for the
ControllerElectMasterrequest inControllerRequestProcessorby adding the missinghandle_elect_masterlogic. This enables the controller to process master election requests for broker groups, which is a core capability for ensuring high availability and automatic failover in the RocketMQ cluster.ElectMasterRequestHeaderfrom the incomingRemotingCommandcontroller_manager.controller().elect_master(...)RemotingCommandcontaining:How Did You Test This Change?
cargo buildcargo testto ensure no functionality was affectedSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.