Skip to content

[ISSUE #3408]Refactor QueryMessageRequestHeader with derive marco RequestHeaderCodec #3476

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

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

donghao526
Copy link
Contributor

@donghao526 donghao526 commented Jun 17, 2025

Which Issue(s) This PR Fixes(Closes)

Fixes #3408

Brief Description

Refactor QueryMessageRequestHeader with derive marco RequestHeaderCodec

How Did You Test This Change?

Running the unit tests local

Summary by CodeRabbit

  • Refactor
    • Improved internal handling of message query requests for better reliability and maintainability. No changes to user-facing functionality.
  • Tests
    • Clarified type annotations in tests to improve code clarity. No changes to test outcomes.

Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Walkthrough

The QueryMessageRequestHeader struct was refactored to use the RequestHeaderCodec derive macro, with all main fields marked as required. Manual implementations of related traits were commented out, and imports adjusted accordingly. Test code was updated with explicit type annotations, but the test logic remained unchanged.

Changes

File(s) Change Summary
rocketmq-remoting/src/protocol/header/query_message_request_header.rs Refactored QueryMessageRequestHeader to use RequestHeaderCodec derive macro; marked fields as required; commented out manual trait implementations and related constants; updated test module with explicit type annotations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant QueryMessageRequestHeader
    participant RequestHeaderCodec (macro)
    User->>QueryMessageRequestHeader: Create instance with required fields
    QueryMessageRequestHeader->>RequestHeaderCodec (macro): Serialize/Deserialize via macro
    RequestHeaderCodec (macro)-->>QueryMessageRequestHeader: Handles encoding/decoding
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor QueryMessageRequestHeader to use derive macro RequestHeaderCodec (#3408)
Ensure the refactor does not introduce new bugs; update unit tests if applicable (#3408)
Ensure the refactor does not negatively impact performance (#3408)
Document any new patterns or architecture changes (#3408)
Test the refactor in different environments (e.g., staging, production) (#3408)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Poem

In the warren where code bunnies dwell,
Macros now handle the headers so well.
Traits once hand-written, now gently asleep,
While required fields hop in a tidy heap.
With a twitch of the nose and a macro’s delight,
The code is much cleaner—oh what a sight!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b1622d and 88f9277.

📒 Files selected for processing (1)
  • rocketmq-remoting/src/protocol/header/query_message_request_header.rs (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • rocketmq-remoting/src/protocol/header/query_message_request_header.rs
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build
  • GitHub Check: test
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: auto-approve
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@donghao526 🚀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💥.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (3)
rocketmq-remoting/src/protocol/header/query_message_request_header.rs (3)

24-44: Clarify required‐field semantics

All business fields are now marked #[required].
Double-check that the derive macro enforces this at both encode and decode time; otherwise deserialisation may silently accept missing data and lead to runtime unwrap()s downstream. If the macro already validates, please add a brief doc-comment on the struct noting that these fields are mandatory so that callers understand the contract.


46-52: Remove large commented blocks

The old constant definitions and hand-written CommandCustomHeader / FromMap implementations are no longer useful and bloat the file. Deleting them instead of commenting keeps history in git while leaving the codebase clean.

Also applies to: 60-149


151-242: Formatting & minor test cleanup

CI reports cargo fmt failure on this file.
Run cargo fmt --all before merging.

In the tests, the explicit type annotations (let header: QueryMessageRequestHeader = …) are unnecessary; the compiler can infer them. Removing them makes the tests slightly cleaner.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8655834 and 8b1622d.

📒 Files selected for processing (1)
  • rocketmq-remoting/src/protocol/header/query_message_request_header.rs (5 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
rocketmq-remoting/src/protocol/header/query_message_request_header.rs

[error] 151-195: cargo fmt check failed due to formatting differences. Please run 'cargo fmt' to format the code.

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: test
  • GitHub Check: auto-approve
🔇 Additional comments (1)
rocketmq-remoting/src/protocol/header/query_message_request_header.rs (1)

18-19: Macro import looks good

rocketmq_macros::RequestHeaderCodec is correctly brought into scope.
No action needed here.

Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.60%. Comparing base (8655834) to head (88f9277).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3476      +/-   ##
==========================================
- Coverage   26.66%   26.60%   -0.06%     
==========================================
  Files         546      546              
  Lines       78050    77978      -72     
==========================================
- Hits        20813    20749      -64     
+ Misses      57237    57229       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@donghao526 🚀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💥.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor♻️]Refactor QueryMessageRequestHeader with derive marco RequestHeaderCodec
4 participants