Skip to content

[ISSUE #9332]♻️Inject remoting command factories into BrokerOuterAPI - #9333

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

[ISSUE #9332]♻️Inject remoting command factories into BrokerOuterAPI#9333
mxsm merged 1 commit into
mainfrom
mxsm/inject-broker-outer-command-factory

Conversation

@mxsm

@mxsm mxsm commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Which Issue(s) This PR Fixes(Closes)

Brief Description

  • Give BrokerOuterAPI an immutable, owner-scoped RemotingCommandFactory.
  • Route all 31 control-plane request constructors and the send/pull request builders through that factory.
  • Preserve the existing constructors as compatibility wrappers that capture the application factory once.
  • Inject the application factory explicitly at the broker composition boundary.

Motivation

BrokerOuterAPI produces outbound commands for NameServer, controller, peer-broker, send, and pull operations. Static constructors bypassed the factory selected by an embedded or test owner, so independently configured owners could not reliably retain distinct remoting versions and serialization types.

Implementation

  • Add explicit factory-aware constructors while keeping existing constructor signatures compatible.
  • Store and clone the immutable factory with the outer API owner.
  • Pass the factory into send and pull request builders.
  • Add regression coverage for independent JSON and ROCKETMQ owners and for both message-path helpers.

How Did You Test This Change?

  • cargo check -p rocketmq-broker --all-features
  • Three focused owner-default regression tests
  • cargo test -p rocketmq-broker --lib --all-features (825 passed, 2 ignored)
  • cargo clippy -p rocketmq-broker --no-deps --all-targets --all-features -- -D warnings
  • cargo clippy --workspace --no-deps --all-targets --all-features -- -D warnings
  • Package-by-package format checks for all 28 root workspace packages
  • cargo +nightly-2026-07-05 check --locked --all-targets --all-features in fuzz/
  • git diff --check

The aggregate Windows cargo fmt --all -- --check invocation still reaches OS error 206 because of the workspace command length. Every root workspace package passed its equivalent non-mutating format check individually.

Compatibility

Request codes, typed headers, bodies, flags, opaque values, RPC hooks, and wire encoding behavior remain unchanged. Existing public constructors continue to use the application defaults; explicit constructors allow owner-specific defaults.

Summary by CodeRabbit

  • New Features

    • Added configurable remoting command settings for broker communications.
    • Broker requests now consistently honor configured protocol versions and serialization formats across sending, pulling, heartbeat, controller, and queue operations.
    • Added construction options for supplying custom remoting command behavior.
  • Bug Fixes

    • Corrected request creation so configured command defaults are preserved instead of relying on global defaults.

@mxsm
mxsm merged commit 3de9261 into main Aug 13, 2026
20 of 27 checks passed
@mxsm
mxsm deleted the mxsm/inject-broker-outer-command-factory branch August 13, 2026 07:20
@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: ed38e3f9-baf2-4173-8c88-5cfeb75679ff

📥 Commits

Reviewing files that changed from the base of the PR and between d2e7d98 and 1a870e1.

📒 Files selected for processing (4)
  • rocketmq-broker/src/broker_runtime/composition.rs
  • rocketmq-broker/src/out_api/broker_outer_api.rs
  • rocketmq-broker/src/out_api/pull.rs
  • rocketmq-broker/src/out_api/send.rs

Walkthrough

BrokerOuterAPI now owns an injectable RemotingCommandFactory. Broker composition supplies the application factory. All outbound broker, send, and pull requests use factory-configured command defaults, with tests covering version and serialization settings.

Changes

Broker remoting factory integration

Layer / File(s) Summary
Factory ownership and construction
rocketmq-broker/src/broker_runtime/composition.rs, rocketmq-broker/src/out_api/broker_outer_api.rs
BrokerOuterAPI stores a RemotingCommandFactory. Existing constructors use the application factory, and new constructors accept an explicit factory. Broker composition supplies that factory.
Broker request construction migration
rocketmq-broker/src/out_api/broker_outer_api.rs
Broker, name-server, controller, heartbeat, queue, and HA requests now use the configured factory.
Send and pull factory propagation
rocketmq-broker/src/out_api/send.rs, rocketmq-broker/src/out_api/pull.rs, rocketmq-broker/src/out_api/broker_outer_api.rs
Send and pull builders receive the factory and preserve its version and serialization defaults. Tests cover independent factory settings and cloning.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

Suggested labels: refactor♻️

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

Poem

A rabbit packs commands with care,
Each factory keeps its settings there.
Send and pull now follow the trail,
With versioned notes in every mail.
Hop, hop—the broker’s path is clear!

✨ 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-broker-outer-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

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

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 ready to review refactor♻️ refactor code waiting-review waiting review this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor♻️] Inject remoting command factories into BrokerOuterAPI

3 participants