Skip to content

[ISSUE #9341]♻️Inject remoting command factories into Controller owners - #9342

Merged
mxsm merged 1 commit into
mainfrom
mxsm/inject-controller-command-factory
Aug 13, 2026
Merged

[ISSUE #9341]♻️Inject remoting command factories into Controller owners#9342
mxsm merged 1 commit into
mainfrom
mxsm/inject-controller-command-factory

Conversation

@mxsm

@mxsm mxsm commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Which Issue(s) This PR Fixes(Closes)

Brief Description

  • Capture one immutable RemotingCommandFactory at each Controller composition boundary.
  • Propagate the factory through ControllerManager, Raft/OpenRaft responses, inbound processors, unsupported-request responses, and broker-role notification requests.
  • Preserve existing constructors as compatibility wrappers while adding explicit injection entry points.
  • Pass the NameServer-owned factory into its embedded Controller.
  • Add owner-isolation, outbound-request, embedded-owner, and source-audit regression coverage.

How Did You Test This Change?

  • cargo test -p rocketmq-controller --lib (174 passed, 3 ignored)
  • cargo test -p rocketmq-controller --tests -- --skip test_five_node_cluster (passed)
  • cargo test -p rocketmq-controller --all-features --lib (175 passed, 3 ignored)
  • cargo test -p rocketmq-controller --all-features --test remoting_command_factory_owner_audit (passed)
  • cargo test -p rocketmq-namesrv --all-features --lib -- --skip config::tests::test_namesrv_config (257 passed)
  • cargo test -p rocketmq-namesrv --features embedded-controller enable_controller_in_namesrv_lifecycle_matches_namesrv_runtime --lib (passed)
  • cargo clippy -p rocketmq-controller --all-targets --all-features -- -D warnings (passed)
  • cargo clippy -p rocketmq-namesrv --all-targets --all-features -- -D warnings (passed)
  • cargo clippy --workspace --no-deps --all-targets --all-features -- -D warnings (passed)
  • cargo +nightly-2026-07-05 check --locked --all-targets --all-features from fuzz/ (passed)
  • cargo fmt -p rocketmq-controller -- --check and cargo fmt -p rocketmq-namesrv -- --check (passed)
  • scripts/runtime-audit.ps1 -SkipBaseline -EnforceBoundaryBaseline (passed)
  • scripts/check-error-hygiene.ps1 (passed)
  • cargo doc -p rocketmq-controller -p rocketmq-namesrv --all-features --no-deps (passed with two pre-existing NameServer invalid-HTML-tag warnings)
  • git diff --check (passed)

The aggregate cargo fmt --all -- --check command remains unavailable on Windows because it exits with OS error 206; both changed packages pass their package-scoped format checks. test_five_node_cluster fails because a learner has not reached the committed-log frontier; the same command reproduces the failure on the unmodified main branch.

Summary by CodeRabbit

  • New Features

    • Added configurable remoting protocol versions and serialization types for Controller requests, responses, and broker notifications.
    • Embedded Controllers now inherit the NameServer’s configured remoting settings.
    • Added construction options for explicitly selecting remoting command defaults.
  • Tests

    • Added coverage verifying custom protocol settings are preserved across Controller operations and embedded initialization.
    • Added safeguards ensuring runtime responses use the configured command factory.

@rocketmq-rust-bot

Copy link
Copy Markdown
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💥.

@mxsm
mxsm merged commit 8448899 into main Aug 13, 2026
27 of 33 checks passed
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 38f873c5-724f-4053-be20-f4e136939d8f

📥 Commits

Reviewing files that changed from the base of the PR and between cc1291c and 940c321.

📒 Files selected for processing (12)
  • rocketmq-controller/src/bin/controller_bootstrap.rs
  • rocketmq-controller/src/controller/broker_role_notifier.rs
  • rocketmq-controller/src/controller/broker_role_notifier/actor.rs
  • rocketmq-controller/src/controller/broker_role_notifier/tests.rs
  • rocketmq-controller/src/controller/controller_manager.rs
  • rocketmq-controller/src/controller/open_raft_controller.rs
  • rocketmq-controller/src/controller/raft_controller.rs
  • rocketmq-controller/src/processor.rs
  • rocketmq-controller/src/processor/controller_request_processor.rs
  • rocketmq-controller/src/typ.rs
  • rocketmq-controller/tests/remoting_command_factory_owner_audit.rs
  • rocketmq-namesrv/src/bootstrap.rs

Walkthrough

The change injects RemotingCommandFactory instances through Controller construction. Controller requests, responses, broker notifications, and embedded NameServer Controllers now use configured protocol defaults. Tests validate factory propagation, serialization metadata, and runtime-owner usage.

Changes

Controller command ownership

Layer / File(s) Summary
Factory-aware response conversion
rocketmq-controller/src/typ.rs
ControllerResponse supports factory-based remoting command conversion while preserving default behavior.
Controller owner composition
rocketmq-controller/src/bin/controller_bootstrap.rs, rocketmq-controller/src/controller/controller_manager.rs, rocketmq-controller/src/controller/raft_controller.rs, rocketmq-controller/src/controller/open_raft_controller.rs, rocketmq-namesrv/src/bootstrap.rs
Constructors store and propagate RemotingCommandFactory instances through Controller ownership and embedded Controller startup.
Runtime command producers
rocketmq-controller/src/controller/open_raft_controller.rs, rocketmq-controller/src/controller/broker_role_notifier.rs, rocketmq-controller/src/controller/broker_role_notifier/actor.rs
OpenRaft responses and broker-role notification requests use the owning factory.
Request processor responses
rocketmq-controller/src/processor.rs, rocketmq-controller/src/processor/controller_request_processor.rs
Unsupported, validation, maintenance, configuration, and timeout responses use configured factories.
Factory isolation validation
rocketmq-controller/tests/remoting_command_factory_owner_audit.rs, rocketmq-controller/src/controller/*/tests.rs, rocketmq-namesrv/src/bootstrap.rs
Tests verify protocol defaults and reject direct static command construction in Controller runtime owners.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NameServer
  participant ControllerManager
  participant ControllerRequestProcessor
  participant OpenRaftController
  NameServer->>ControllerManager: inject RemotingCommandFactory
  ControllerManager->>OpenRaftController: pass factory during construction
  ControllerManager->>ControllerRequestProcessor: expose configured factory
  ControllerRequestProcessor->>OpenRaftController: request controller operation
  OpenRaftController-->>ControllerRequestProcessor: create response with factory
Loading

Possibly related PRs

Suggested reviewers: rocketmq-rust-bot, spacexcn, teslarustor

Poem

I tucked a factory under each leafy tree,
So every command keeps its owner’s decree.
The brokers send requests with defaults held tight,
While controllers answer in matching light.
Hop, hop—the wire stays right!

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mxsm/inject-controller-command-factory

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

Comment @coderabbitai help to get the list of available commands.

@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Aug 13, 2026
@mxsm
mxsm deleted the mxsm/inject-controller-command-factory branch August 13, 2026 11:32
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 refactor♻️ refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor♻️] Inject remoting command factories into Controller owners

3 participants