Skip to content

[ISSUE #3501]🚀Implement GeneralHAService and controller mode for unified HA architecture✨#3502

Merged
rocketmq-rust-bot merged 1 commit intomainfrom
feature-3501
Jun 22, 2025
Merged

[ISSUE #3501]🚀Implement GeneralHAService and controller mode for unified HA architecture✨#3502
rocketmq-rust-bot merged 1 commit intomainfrom
feature-3501

Conversation

@mxsm
Copy link
Owner

@mxsm mxsm commented Jun 22, 2025

Which Issue(s) This PR Fixes(Closes)

Fixes #3501

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features

    • Added a new configuration option to enable controller mode for message storage.
    • Introduced a new high-availability (HA) service variant to support controller mode, preparing for future enhancements.
  • Improvements

    • HA service logic now selects the appropriate mode based on configuration, improving flexibility for different deployment scenarios.
  • Cleanup

    • Removed obsolete HA service wrapper and related unused code, streamlining the codebase.

Copilot AI review requested due to automatic review settings June 22, 2025 07:08
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 22, 2025

Walkthrough

The changes introduce a unified high-availability (HA) service architecture. A new GeneralHAService selects between DefaultHAService and AutoSwitchHAService based on a new enable_controller_mode configuration flag. The legacy HAServiceWrapper is removed, trait interfaces are simplified, and both HA service variants are refactored for clarity and configuration-driven instantiation.

Changes

File(s) Change Summary
rocketmq-store/src/config/message_store_config.rs Added enable_controller_mode boolean flag to MessageStoreConfig with serde support and default value.
rocketmq-store/src/ha.rs Removed HAServiceWrapper struct and all associated methods and trait implementations; now only contains submodules.
rocketmq-store/src/ha/auto_switch/auto_switch_ha_service.rs Introduced AutoSwitchHAService struct with stubbed implementations for HAService trait methods.
rocketmq-store/src/ha/default_ha_service.rs Updated DefaultHAService to derive Default, added explicit empty struct, cleaned up imports and removed init.
rocketmq-store/src/ha/general_ha_service.rs Refactored GeneralHAService to select and delegate to the appropriate HA service based on configuration.
rocketmq-store/src/ha/ha_service.rs Removed (commented out) generic init method from the RocketHAService trait; cleaned up unused imports.

Sequence Diagram(s)

sequenceDiagram
    participant Config as MessageStoreConfig
    participant Store as LocalFileMessageStore
    participant GeneralHA as GeneralHAService
    participant DefaultHA as DefaultHAService
    participant AutoSwitchHA as AutoSwitchHAService

    Config->>Store: Provide enable_controller_mode flag
    Store->>GeneralHA: Pass config on init
    GeneralHA->>GeneralHA: Check enable_controller_mode
    alt enable_controller_mode == true
        GeneralHA->>AutoSwitchHA: Initialize AutoSwitchHAService
        GeneralHA->>AutoSwitchHA: Delegate start()
    else enable_controller_mode == false
        GeneralHA->>DefaultHA: Initialize DefaultHAService
        GeneralHA->>DefaultHA: Delegate start()
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Dynamic Service Selection, Controller Mode Support, Configuration-Driven (3501)
Simplified HA Architecture, Removal of Wrapper Patterns (3501)
Enhanced HAService Trait: Simplified Interface, Removed Generic Init (3501)
DefaultHAService and AutoSwitchHAService: Default Trait, Placeholder Implementations (3501)
Controller Mode Flag in Config, Serde Support, Default Values (3501)

Poem

In the warren of code, a new path we lay,
With toggles for HA, we now choose our way.
Old wrappers are gone, the service is clean,
Controller or default—just flip the machine!
🐇 With a hop and a log, we’re ready to play,
High availability, the RocketMQ way!

✨ 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 rocketmq-rust-bot self-requested a review June 22, 2025 07:08
@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💥.

@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Jun 22, 2025
Copy link
Contributor

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 implements a unified HA architecture by introducing a new GeneralHAService and enabling controller mode via configuration. Key changes include:

  • Removing the generic init method from the HAService trait and providing a specialized implementation in GeneralHAService.
  • Adding conditional initialization in GeneralHAService to select between AutoSwitchHAService and DefaultHAService based on the configuration.
  • Updating the MessageStoreConfig to support controller mode and removing the obsolete HAServiceWrapper in the HA module.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rocketmq-store/src/ha/ha_service.rs Comments out the generic init method from the trait, indicating deprecation.
rocketmq-store/src/ha/general_ha_service.rs Adds a new implementation for HA service and branches logic based on controller mode.
rocketmq-store/src/ha/default_ha_service.rs Refactors DefaultHAService to use the Default derive and removes unimplemented init.
rocketmq-store/src/ha/auto_switch/auto_switch_ha_service.rs Introduces AutoSwitchHAService with several todo!() implementations and an incorrect error message.
rocketmq-store/src/ha.rs Removes the HAServiceWrapper, streamlining the HA module.
rocketmq-store/src/config/message_store_config.rs Adds the enable_controller_mode flag to the configuration.
Comments suppressed due to low confidence (1)

rocketmq-store/src/ha/general_ha_service.rs:45

  • The init method now accepts only a LocalFileMessageStore, which limits its flexibility compared to the previous generic MessageStore bound. Consider generalizing the parameter if other MessageStore types are expected.
    pub(crate) fn init(&mut self, message_store: ArcMut<LocalFileMessageStore>) -> HAResult<()> {


impl HAService for AutoSwitchHAService {
fn start(&mut self) -> HAResult<()> {
error!("DefaultHAService start not implemented");
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

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

The error message in this start() method incorrectly references 'DefaultHAService'; consider updating it to 'AutoSwitchHAService' for clarity.

Suggested change
error!("DefaultHAService start not implemented");
error!("AutoSwitchHAService start not implemented");

Copilot uses AI. Check for mistakes.
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 (1)
rocketmq-store/src/ha/auto_switch/auto_switch_ha_service.rs (1)

36-39: Fix the error message to match the service name.

The error message incorrectly references "DefaultHAService" but this is the AutoSwitchHAService implementation.

Apply this fix:

-        error!("DefaultHAService start not implemented");
+        error!("AutoSwitchHAService start not implemented");
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 98d2a33 and fbe8e7f.

📒 Files selected for processing (6)
  • rocketmq-store/src/config/message_store_config.rs (2 hunks)
  • rocketmq-store/src/ha.rs (0 hunks)
  • rocketmq-store/src/ha/auto_switch/auto_switch_ha_service.rs (1 hunks)
  • rocketmq-store/src/ha/default_ha_service.rs (1 hunks)
  • rocketmq-store/src/ha/general_ha_service.rs (1 hunks)
  • rocketmq-store/src/ha/ha_service.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • rocketmq-store/src/ha.rs
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: auto-approve
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (8)
rocketmq-store/src/config/message_store_config.rs (2)

810-811: LGTM! Clean configuration field addition.

The new enable_controller_mode field follows established patterns with proper serde annotation and integrates well with the unified HA architecture.


1002-1002: LGTM! Default value properly initialized.

The default value of false for enable_controller_mode ensures backward compatibility.

rocketmq-store/src/ha/ha_service.rs (1)

32-32: LGTM! Trait interface simplification.

Removing the generic init method from the trait is appropriate as initialization logic is now handled in concrete implementations like GeneralHAService.

rocketmq-store/src/ha/default_ha_service.rs (1)

50-51: LGTM! Clean struct definition with Default derive.

The Default derive makes the struct easily instantiable and aligns with the new initialization pattern used in GeneralHAService.

rocketmq-store/src/ha/general_ha_service.rs (3)

39-42: LGTM! Well-structured composition pattern.

The struct design using optional fields for different HA services enables clean service selection based on configuration.


45-55: LGTM! Configuration-driven service initialization.

The initialization logic properly selects between HA services based on the enable_controller_mode flag, implementing the unified HA architecture as intended.


59-68: LGTM! Proper delegation with error handling.

The start method correctly delegates to the initialized service and provides clear error handling when no service is available.

rocketmq-store/src/ha/auto_switch/auto_switch_ha_service.rs (1)

33-117: LGTM! Clean stub implementation for new HA service.

The AutoSwitchHAService provides a good foundation for the controller mode HA service with appropriate placeholder methods.

@codecov
Copy link

codecov bot commented Jun 22, 2025

Codecov Report

Attention: Patch coverage is 1.66667% with 59 lines in your changes missing coverage. Please review.

Project coverage is 26.28%. Comparing base (98d2a33) to head (fbe8e7f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...store/src/ha/auto_switch/auto_switch_ha_service.rs 0.00% 47 Missing ⚠️
rocketmq-store/src/ha/general_ha_service.rs 0.00% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3502   +/-   ##
=======================================
  Coverage   26.28%   26.28%           
=======================================
  Files         550      550           
  Lines       78356    78341   -15     
=======================================
+ Hits        20592    20593    +1     
+ Misses      57764    57748   -16     

☔ 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 b48f78b into main Jun 22, 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 Jun 22, 2025
@mxsm mxsm deleted the feature-3501 branch June 26, 2025 03:34
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 feature🚀 Suggest an idea for this project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature🚀] Implement GeneralHAService and controller mode for unified HA architecture

4 participants