Skip to content
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 #2855]🚀Add ScheduleMessageHook to MessageStore💫 #2856

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

mxsm
Copy link
Owner

@mxsm mxsm commented Mar 25, 2025

Which Issue(s) This PR Fixes(Closes)

Fixes #2855

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features

    • Introduced an enhanced scheduling capability within the messaging process for improved timing and reliability.
  • Refactor

    • Streamlined the underlying hook management to better integrate the new scheduling functionality.

@Copilot Copilot bot review requested due to automatic review settings March 25, 2025 15:03
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

The changes integrate the newly created ScheduleMessageHook into the RocketMQ broker. An import for ScheduleMessageHook is added in the broker runtime, and the register_message_store_hook method is updated to instantiate and register it using a cloned reference to the broker's runtime inner state. Additionally, a new implementation file defines the ScheduleMessageHook struct with its constructor. Existing hook registrations remain intact.

Changes

File(s) Change Summary
rocketmq-broker/src/broker_runtime.rs Added import for ScheduleMessageHook and updated register_message_store_hook to instantiate and register the new hook using a cloned broker_runtime_inner.
rocketmq-broker/src/hook/schedule_message_hook.rs Introduced the ScheduleMessageHook struct along with a new constructor new that initializes it with an ArcMut<BrokerRuntimeInner<MS>>.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant BR as BrokerRuntime
    participant SMH as ScheduleMessageHook
    participant MS as MessageStore

    Client->>BR: register_message_store_hook()
    BR->>SMH: new(cloned broker_runtime_inner)
    SMH-->>BR: Hook instance created
    BR->>MS: Register ScheduleMessageHook
Loading

Assessment against linked issues

Objective Addressed Explanation
Add ScheduleMessageHook to MessageStore (#2855)

Possibly related PRs

Suggested labels

feature🚀, auto merge, ready to review, waiting-review, AI review first

Suggested reviewers

  • TeslaRustor
  • SpaceXCN
  • rocketmq-rust-bot

Poem

I’m a bunny in the code garden so bright,
Hopping through hooks from morning to night.
ScheduleMessageHook springs to life with delight,
In the ecosystem’s maze, it shines a new light.
Carrots and code—what a marvelous 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 edd6035 and 353804f.

📒 Files selected for processing (2)
  • rocketmq-broker/src/broker_runtime.rs (2 hunks)
  • rocketmq-broker/src/hook/schedule_message_hook.rs (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
rocketmq-broker/src/hook/schedule_message_hook.rs (1)
rocketmq-broker/src/broker_runtime.rs (1)
  • new (124-232)
rocketmq-broker/src/broker_runtime.rs (7)
rocketmq-broker/src/topic/manager/topic_config_manager.rs (1)
  • broker_runtime_inner (585-587)
rocketmq-broker/src/processor/pop_message_processor.rs (3)
  • new (95-121)
  • new (1556-1561)
  • new (1597-1602)
rocketmq-broker/src/processor/admin_broker_processor/topic_request_handler.rs (1)
  • new (62-66)
rocketmq-broker/src/processor/consumer_manage_processor.rs (1)
  • new (46-50)
rocketmq-broker/src/processor/reply_message_processor.rs (1)
  • new (58-71)
rocketmq-broker/src/processor/send_message_processor.rs (1)
  • new (183-198)
rocketmq-broker/src/hook/schedule_message_hook.rs (1)
  • new (32-36)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: test
  • GitHub Check: auto-approve
🔇 Additional comments (3)
rocketmq-broker/src/hook/schedule_message_hook.rs (1)

31-37: Implementation looks good!

The constructor is properly implemented to initialize a new ScheduleMessageHook instance with the provided broker_runtime_inner. This follows the same pattern used by other hooks in the codebase, maintaining consistency in the implementation style.

rocketmq-broker/src/broker_runtime.rs (2)

70-70: Import looks good!

The import statement for ScheduleMessageHook is correctly added to bring the hook into scope for registration.


496-505:

✅ Verification successful

Hook registration implementation looks good!

The ScheduleMessageHook is properly registered in the register_message_store_hook method alongside the existing hooks. The broker runtime inner state is correctly cloned and passed to the hook constructor, maintaining the same pattern used for other hooks.

Would be beneficial to verify that the message store hooks are called in the correct order. Run the following script to check if there are any dependencies between the hooks that might require a specific order:


🏁 Script executed:

#!/bin/bash
# Check if there are any dependencies between hooks or specific order requirements

echo "Analyzing hook execution order:"
rg -A 3 "execute_before_put_message" --type rust
echo "---"
echo "Checking if the order of hooks matters in other parts of code:"
rg -C 3 "set_put_message_hook" --type rust

Length of output: 6299


Hook registration and execution order verified!
The ScheduleMessageHook is properly registered alongside the other hooks in the register_message_store_hook method. The broker runtime inner state is correctly cloned and passed to the hook constructor, following the same established pattern.

Our analysis using the provided script confirms that the hooks are executed sequentially—that is, in the order they are registered—as observed in both the default and local file message store implementations. Please ensure that this sequential execution order satisfies any inter-hook dependencies required by your business logic.

✨ 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.
    • 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

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

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new ScheduleMessageHook to the MessageStore as part of the resolution for ISSUE #2855. It introduces a new hook in the schedule_message_hook.rs file and registers it in the broker_runtime to be used during message processing.

  • Added a new ScheduleMessageHook implementation with a constructor in schedule_message_hook.rs.
  • Updated broker_runtime.rs to import and register the new hook.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rocketmq-broker/src/hook/schedule_message_hook.rs Introduces the ScheduleMessageHook and its constructor.
rocketmq-broker/src/broker_runtime.rs Imports and registers the ScheduleMessageHook in the message store hook chain.
Comments suppressed due to low confidence (1)

rocketmq-broker/src/broker_runtime.rs:504

  • Multiple calls to 'set_put_message_hook' might override each other if the implementation does not support chaining. Consider verifying or updating the hook registration mechanism to ensure that all intended hooks are executed.
                .set_put_message_hook(Box::new(ScheduleMessageHook::new(broker_runtime_inner)))

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

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

Project coverage is 27.55%. Comparing base (edd6035) to head (353804f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
rocketmq-broker/src/hook/schedule_message_hook.rs 0.00% 5 Missing ⚠️
rocketmq-broker/src/broker_runtime.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2856      +/-   ##
==========================================
- Coverage   27.55%   27.55%   -0.01%     
==========================================
  Files         527      527              
  Lines       78046    78054       +8     
==========================================
  Hits        21504    21504              
- Misses      56542    56550       +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.

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

@rocketmq-rust-bot rocketmq-rust-bot merged commit 7faf5e0 into main Mar 25, 2025
23 of 24 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Mar 25, 2025
@mxsm mxsm deleted the feature-2855 branch March 26, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI review first Ai review pr first approved PR has approved auto merge enhancement⚡️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement⚡️] Add ScheduleMessageHook to MessageStore
3 participants