mxsm / rocketmq-rust

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

[ISSUE #1089]🔥Optimize api according to rust api-guidelines🎨 #1090

Closed mxsm closed 2 weeks ago

mxsm commented 2 weeks ago

Which Issue(s) This PR Fixes(Closes)

Fixes #1089

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

Release Notes

These changes aim to enhance the overall performance and reliability of the messaging system.

coderabbitai[bot] commented 2 weeks ago

[!WARNING]

Rate limit exceeded

@mxsm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
📥 Commits Files that changed from the base of the PR and between 1556673e45726817662a3c41d0ed2017e7a47951 and e3f64bfaf1d3a0d8ae3791af3fe86a0e352c0832.

Walkthrough

The changes primarily focus on simplifying the handling of request and response bodies across various structs in the rocketmq project. This includes removing unnecessary wrappers around body parameters, such as Some() and Bytes, in methods across multiple files. The modifications enhance code readability and maintainability while preserving the existing logic and control flow.

Changes

File Path Change Summary
rocketmq-broker/src/out_api/broker_outer_api.rs Simplified body parameter handling in create_request, register_broker, lock_batch_mq_async, and unlock_batch_mq_async methods.
rocketmq-broker/src/processor/admin_broker_processor/batch_mq_handler.rs Streamlined response creation in lock_natch_mq by removing Some() wrapper around response body.
rocketmq-broker/src/processor/admin_broker_processor/broker_config_request_handler.rs Simplified body handling in get_broker_config and get_broker_runtime_info methods by removing Some(Bytes::from(...)).
rocketmq-broker/src/processor/admin_broker_processor/consumer_request_handler.rs Simplified response body assignment in get_consumer_connection_list, get_consume_stats, and get_all_consumer_offset methods.
rocketmq-broker/src/processor/admin_broker_processor/topic_request_handler.rs Removed Bytes wrapping in response body settings across multiple methods for topic management.
rocketmq-broker/src/processor/consumer_manage_processor.rs Eliminated Bytes dependency in get_consumer_list_by_group method, simplifying response body handling.
rocketmq-broker/src/processor/default_pull_message_result_handler.rs Modified handle method to conditionally set response body based on presence.
rocketmq-broker/src/processor/query_message_processor.rs Enhanced consistency in message body handling in query_message and view_message_by_id methods.
rocketmq-broker/src/processor/reply_message_processor.rs Improved message body handling in push_reply_message and process_reply_message_request methods.
rocketmq-client/src/implementation/mq_client_api_impl.rs Streamlined request body handling in send_message, send_heartbeat, check_client_in_broker, unlock_batch_mq, and lock_batch_mq methods.
rocketmq-client/src/producer/default_mq_producer.rs Updated as_any and as_any_mut methods to explicitly reference std::any::Any.
rocketmq-namesrv/src/processor/client_request_processor.rs Simplified body assignment in get_route_info_by_topic method.
rocketmq-namesrv/src/processor/default_request_processor.rs Streamlined response body handling in various methods by removing unnecessary option wrapping.
rocketmq-remoting/src/protocol/remoting_command.rs Updated set_body and set_body_mut_ref methods to accept non-optional parameters.
rocketmq-remoting/src/rpc/rpc_client_utils.rs Enhanced error handling in create_command_for_rpc_request method regarding body encoding.
rocketmq-remoting/src/codec/remoting_command_codec.rs Simplified body setting in encode method by removing Some() wrapper around body assignment.

Assessment against linked issues

Objective Addressed Explanation
Optimize API according to Rust API guidelines (#1089)

Possibly related PRs

Suggested reviewers

Poem

In the code where rabbits hop,
We’ve streamlined things, no need to stop.
With bodies clear and logic bright,
Our API shines, a joyful sight!
Hopping through the lines with glee,
Simplified for you and me! 🐇✨


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 , please review it.` - `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 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 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](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
mxsm commented 2 weeks ago

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

mxsm commented 2 weeks ago

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

mxsm commented 2 weeks ago

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

mxsm commented 2 weeks ago

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

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 5.17241% with 55 lines in your changes missing coverage. Please review.

Project coverage is 19.68%. Comparing base (fe0ccb3) to head (e3f64bf). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...namesrv/src/processor/default_request_processor.rs 0.00% 11 Missing :warning:
...mq-broker/src/processor/query_message_processor.rs 0.00% 7 Missing :warning:
...or/admin_broker_processor/topic_request_handler.rs 0.00% 6 Missing :warning:
...mq-broker/src/processor/reply_message_processor.rs 0.00% 5 Missing :warning:
rocketmq-broker/src/out_api/broker_outer_api.rs 0.00% 4 Missing :warning:
...mq-client/src/implementation/mq_client_api_impl.rs 0.00% 4 Missing :warning:
...admin_broker_processor/consumer_request_handler.rs 0.00% 3 Missing :warning:
...c/processor/default_pull_message_result_handler.rs 0.00% 3 Missing :warning:
rocketmq-remoting/src/protocol/remoting_command.rs 40.00% 3 Missing :warning:
..._broker_processor/broker_config_request_handler.rs 0.00% 2 Missing :warning:
... and 5 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1090 +/- ## ========================================== - Coverage 19.69% 19.68% -0.01% ========================================== Files 431 431 Lines 36256 36264 +8 ========================================== Hits 7140 7140 - Misses 29116 29124 +8 ```

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