-
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 #1507]♻️Refactor BrokerHeartbeatRequestHeader with derive marco RequestHeaderCodec #1589
Conversation
…marco RequestHeaderCodec
WalkthroughThe changes in this pull request involve a complete refactor of the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
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
|
🔊@Happy-debug-lang 🚀Thanks for your contribution 🎉. CodeRabbit(AI) will review your code first 🔥 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1589 +/- ##
==========================================
+ Coverage 25.32% 25.46% +0.14%
==========================================
Files 459 459
Lines 60342 60352 +10
==========================================
+ Hits 15282 15371 +89
+ Misses 45060 44981 -79 ☔ 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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
rocketmq-remoting/src/protocol/header/broker/broker_heartbeat_request_header.rs (1)
55-157
: Add tests for serialization and deserializationThe current tests verify the initialization of
BrokerHeartbeatRequestHeader
but do not test its serialization and deserialization behaviors. Consider adding unit tests to ensure that the struct correctly serializes to and deserializes from the expected formats, particularly enforcing the presence of required fields during deserialization.
fn broker_heartbeat_request_header_with_empty_values() { | ||
let header = BrokerHeartbeatRequestHeader { | ||
cluster_name: CheetahString::from(""), | ||
broker_addr: CheetahString::from(""), | ||
broker_name: CheetahString::from(""), | ||
broker_id: None, | ||
epoch: None, | ||
max_offset: None, | ||
confirm_offset: None, | ||
heartbeat_timeout_mills: None, | ||
election_priority: None, | ||
}; | ||
assert_eq!(header.cluster_name, CheetahString::from("")); | ||
assert_eq!(header.broker_addr, CheetahString::from("")); | ||
assert_eq!(header.broker_name, CheetahString::from("")); | ||
assert!(header.broker_id.is_none()); | ||
assert!(header.epoch.is_none()); | ||
assert!(header.max_offset.is_none()); | ||
assert!(header.confirm_offset.is_none()); | ||
assert!(header.heartbeat_timeout_mills.is_none()); | ||
assert!(header.election_priority.is_none()); | ||
} |
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.
🛠️ Refactor suggestion
Validate that required fields are not empty
In the test broker_heartbeat_request_header_with_empty_values
, the required fields cluster_name
, broker_addr
, and broker_name
are initialized with empty strings. If empty strings are invalid for these required fields, consider adding validation to ensure these fields are not empty.
Which Issue(s) This PR Fixes(Closes)
Fixes #1507
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
BrokerHeartbeatRequestHeader
structure with enhanced serialization capabilities.cluster_name
,broker_addr
, andbroker_name
.Tests
BrokerHeartbeatRequestHeader
under various scenarios.