mxsm / rocketmq-rust

🚀Apache RocketMQ Rust implementation. Faster, safer, and with lower memory usage.
https://docs.rs/rocketmq-rust
Apache License 2.0
538 stars 66 forks source link

[ISSUE #950]✨Support RequestCode GET_MAX_OFFSET/GET_MIN_OFFSET(30/31) in AdminBrokerProcessor🔥 #952

Closed mxsm closed 2 weeks ago

mxsm commented 2 weeks ago

Which Issue(s) This PR Fixes(Closes)

Fixes #950

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

mxsm commented 2 weeks ago

🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥

coderabbitai[bot] commented 2 weeks ago

[!CAUTION]

Review failed

The pull request is closed.

Walkthrough

The changes involve significant modifications across various components of the RocketMQ broker and remoting system. Key updates include the introduction of new request handlers for offset queries, enhancements to the AdminBrokerProcessor, and the implementation of generic types for RPC requests and headers. Additionally, several method signatures have been updated for clarity and consistency, reflecting a shift towards more type-safe and flexible interactions within the system.

Changes

Files Change Summary
rocketmq-broker/src/broker_runtime.rs, rocketmq-broker/src/processor/admin_broker_processor.rs, rocketmq-broker/src/processor/admin_broker_processor/offset_request_handler.rs Added broker_out_api to the BrokerRequestProcessor and AdminBrokerProcessor constructors. Introduced OffsetRequestHandler for handling maximum and minimum offset requests. Updated request handling logic to include new cases for offset queries.
rocketmq-broker/src/processor/consumer_manage_processor.rs, rocketmq-broker/src/processor/pull_message_processor.rs, rocketmq-broker/src/processor/reply_message_processor.rs Updated method signatures to improve clarity by renaming methods from with_ to set_, enhancing the understanding of their purpose. Simplified handling of request headers in PullMessageProcessor.
rocketmq-remoting/src/clients/client.rs, rocketmq-remoting/src/net/channel.rs, rocketmq-remoting/src/remoting_server/server.rs Changed response_table type to ArcRefCellWrapper<HashMap<i32, ResponseFuture>> for concurrency control. Updated Channel constructor to accept response_table. Enhanced connection handling with improved state management.
rocketmq-remoting/src/protocol/header/*.rs Introduced new modules and request header structures for handling "Get Max Offset" and "Get Min Offset" requests. Renamed methods in TopicRequestHeaderTrait to follow a consistent setter naming convention.
rocketmq-remoting/src/rpc/rpc_client.rs, rocketmq-remoting/src/rpc/rpc_client_hook.rs, rocketmq-remoting/src/rpc/rpc_client_impl.rs, rocketmq-remoting/src/rpc/rpc_request.rs Updated RpcClientLocal and RpcClientHook traits to include generic type parameters for enhanced flexibility. Transitioned from boxed trait objects to function pointers for client hooks. Modified RpcRequest structure to be generic, accommodating various header types.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Broker
    participant OffsetRequestHandler

    Client->>Broker: Request Max Offset
    Broker->>OffsetRequestHandler: Handle Request
    OffsetRequestHandler->>Broker: Retrieve Max Offset
    Broker-->>Client: Return Max Offset
sequenceDiagram
    participant Client
    participant Broker
    participant RpcClient

    Client->>RpcClient: Send RPC Request
    RpcClient->>Broker: Forward Request
    Broker-->>RpcClient: Return Response
    RpcClient-->>Client: Send Response

Assessment against linked issues

Objective Addressed Explanation
Support RequestCode GET_MAX_OFFSET/GET_MIN_OFFSET (30/31) (950)

Poem

🐰 In fields of code, I hop with glee,
New handlers sprout like flowers, you see!
With offsets and requests, we dance and play,
A better RocketMQ, brightens the day!
So raise your paws, let's celebrate,
For changes bring joy, oh isn't it great? 🎉


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?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `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 generate unit testing code for this file.` - `@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 generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@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.` 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 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 368 lines in your changes missing coverage. Please review.

Project coverage is 22.41%. Comparing base (ce309a9) to head (8d3e914). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...r/admin_broker_processor/offset_request_handler.rs 0.00% 133 Missing :warning:
...c/protocol/header/get_max_offset_request_header.rs 0.00% 80 Missing :warning:
...c/protocol/header/get_min_offset_request_header.rs 0.00% 69 Missing :warning:
rocketmq-remoting/src/rpc/rpc_client_impl.rs 0.00% 25 Missing :warning:
...tmq-broker/src/processor/admin_broker_processor.rs 0.00% 10 Missing :warning:
rocketmq-remoting/src/clients/client.rs 0.00% 6 Missing :warning:
...ge_operation_header/send_message_request_header.rs 0.00% 6 Missing :warning:
...operation_header/send_message_request_header_v2.rs 0.00% 6 Missing :warning:
...src/protocol/header/pull_message_request_header.rs 0.00% 6 Missing :warning:
...col/header/query_consumer_offset_request_header.rs 0.00% 6 Missing :warning:
... and 8 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #952 +/- ## ========================================== - Coverage 22.63% 22.41% -0.23% ========================================== Files 361 364 +3 Lines 29477 29781 +304 ========================================== + Hits 6673 6674 +1 - Misses 22804 23107 +303 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.