-
Notifications
You must be signed in to change notification settings - Fork 111
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
[ISSUE #1511]♻️Refactor NotifyMinBrokerIdChangeRequestHeader with derive marco RequestHeaderCodec #2316
Conversation
…ive marco RequestHeaderCodec
WalkthroughThe pull request focuses on refactoring 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🔥! 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💥. |
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
🔭 Outside diff range comments (1)
rocketmq-remoting/src/protocol/header/namesrv/brokerid_change_request_header.rs (1)
RequestHeaderCodec usage needs standardization across request headers
The struct implementation in
brokerid_change_request_header.rs
follows the correct pattern with RequestHeaderCodec. However, there are inconsistencies across the codebase where some request header structs are missing the RequestHeaderCodec derive macro.
- Consider standardizing the derive macro usage across all request header structs in future refactoring
- Ensure new request headers consistently use the RequestHeaderCodec pattern
🔗 Analysis chain
Line range hint
23-38
: LGTM! RequestHeaderCodec derive macro added correctly.The struct definition is well-structured with:
- Appropriate use of Option for optional fields
- Consistent serde rename attributes for Java compatibility
- RequestHeaderCodec derive macro replacing manual FromMap implementation
Let's verify the RequestHeaderCodec macro implementation:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if RequestHeaderCodec is consistently used across similar request headers ast-grep --pattern 'struct $name:ident { $$$ }' -l rust | xargs rg "RequestHeaderCodec" -l | wc -lLength of output: 554
Script:
#!/bin/bash # Find all request header structs and check RequestHeaderCodec usage echo "=== Request Header Structs ===" rg "struct \w+RequestHeader" -B 1 --no-filename | sort | uniq echo -e "\n=== Missing RequestHeaderCodec ===" # Find structs without RequestHeaderCodec in the previous line rg "struct \w+RequestHeader" -B 1 --no-filename | grep -B 1 "struct" | grep -v "RequestHeaderCodec" | grep -v "struct" || echo "None found"Length of output: 5489
🧹 Nitpick comments (1)
rocketmq-remoting/src/protocol/header/namesrv/brokerid_change_request_header.rs (1)
59-99
: Add tests for RequestHeaderCodec functionality.The current tests cover constructor and default implementation well. However, consider adding tests for the RequestHeaderCodec functionality to ensure proper serialization/deserialization behavior.
Here's a suggested test addition:
#[test] fn test_request_header_codec() { let header = NotifyMinBrokerIdChangeRequestHeader::new( Some(1), Some(CheetahString::from("broker1")), Some(CheetahString::from("addr1")), Some(CheetahString::from("addr2")), Some(CheetahString::from("addr3")), ); // Test serialization to HashMap let map = header.to_map(); assert_eq!(map.get("minBrokerId").unwrap(), "1"); assert_eq!(map.get("brokerName").unwrap(), "broker1"); // Test deserialization from HashMap let decoded = NotifyMinBrokerIdChangeRequestHeader::from_map(&map).unwrap(); assert_eq!(decoded.min_broker_id, header.min_broker_id); assert_eq!(decoded.broker_name, header.broker_name); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-remoting/src/protocol/header/namesrv/brokerid_change_request_header.rs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: build (windows-latest, nightly)
- GitHub Check: build (windows-latest, stable)
- GitHub Check: build (macos-latest, nightly)
- GitHub Check: build (macos-latest, stable)
- GitHub Check: test
- GitHub Check: build
- GitHub Check: build (ubuntu-latest, nightly)
- GitHub Check: auto-approve
- GitHub Check: build (ubuntu-latest, stable)
🔇 Additional comments (2)
rocketmq-remoting/src/protocol/header/namesrv/brokerid_change_request_header.rs (2)
19-19
: LGTM! Import added for RequestHeaderCodec derive macro.The import is correctly added to support the new derive macro usage.
Line range hint
40-57
: LGTM! Constructor implementation is clean and well-structured.The
new
method provides a clear way to construct the header with all optional fields. The removal of theFromMap
trait implementation is appropriate asRequestHeaderCodec
now handles the serialization/deserialization.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2316 +/- ##
==========================================
+ Coverage 28.20% 28.28% +0.08%
==========================================
Files 504 504
Lines 72470 72422 -48
==========================================
+ Hits 20440 20485 +45
+ Misses 52030 51937 -93 ☔ View full report in Codecov by Sentry. |
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 #1511
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
RequestHeaderCodec
FromMap
andCommandCustomHeader
trait implementations