Skip to content

Conversation

@mxsm
Copy link
Owner

@mxsm mxsm commented Jan 2, 2026

Which Issue(s) This PR Fixes(Closes)

Fixes #5364

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

Release Notes

  • New Features

    • Added enhanced configuration options for message tracing batch size and metadata retrieval page size.
    • Introduced improved configuration accessor methods for better control over client settings.
    • Added utility methods for configuration cloning and reset operations.
  • Bug Fixes

    • Improved null safety handling in configuration initialization.
  • Deprecated

    • One configuration method marked as deprecated; use recommended alternative instead.

✏️ Tip: You can customize this high-level summary in your review settings.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 2, 2026

Walkthrough

This PR enhances ClientConfig with two new configuration fields (trace_msg_batch_num and max_page_size_in_get_metadata), adds comprehensive getter/setter methods for all internal fields, introduces utility methods for cloning and resetting configurations, improves safety in client ID building logic, and marks the without_namespace method as deprecated.

Changes

Cohort / File(s) Summary
ClientConfig Structure & Access
rocketmq-client/src/base/client_config.rs
Added two new public fields: trace_msg_batch_num (default 10) and max_page_size_in_get_metadata (default 2000). Introduced comprehensive getter/setter pairs for all configuration fields including IP, instance name, intervals, timeouts, flags, and the new fields. Added clone_client_config() and reset_client_config() utility methods. Improved build_mq_client_id with safer None handling for client_ip and String pre-allocation. Marked without_namespace deprecated. Updated Display implementation for the new fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A config renaissance takes flight,
With trace fields and getters so right,
Safe builders that shine,
With logic refined—
The rabbit hops higher tonight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes numerous public getters/setters and utility methods (clone_client_config, reset_client_config) beyond the stated trace and metadata settings. Clarify whether the extensive API additions (getters, setters, utility methods, deprecation) are within scope of issue #5364 or should be separate PRs.
Linked Issues check ❓ Inconclusive The PR implements the titled enhancement to ClientConfig with new trace and metadata pagination settings, though the linked issue #5364 lacks detailed requirements. The linked issue #5364 provides minimal context; verify that the implementation aligns with intended functionality for trace batching and metadata pagination.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding trace and metadata pagination settings (trace_msg_batch_num and max_page_size_in_get_metadata) to ClientConfig.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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

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

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: 2

🧹 Nitpick comments (2)
rocketmq-client/src/base/client_config.rs (2)

203-213: Capacity estimate could be more accurate when client_ip is None.

The pre-allocation reserves 15 bytes for client_ip even when it's None, but line 211-213 shows nothing is pushed in that case. This is a minor inefficiency, not a bug.

🔎 Suggested improvement
-        let estimated_capacity = self.client_ip.as_ref().map(|ip| ip.len()).unwrap_or(15)
+        let estimated_capacity = self.client_ip.as_ref().map(|ip| ip.len()).unwrap_or(0)

541-544: Consider removing redundant wrapper.

clone_client_config simply delegates to self.clone(). Since ClientConfig derives Clone, callers can call .clone() directly. This wrapper adds no value.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 564ec23 and efc2aae.

📒 Files selected for processing (1)
  • rocketmq-client/src/base/client_config.rs
🧰 Additional context used
🧬 Code graph analysis (1)
rocketmq-client/src/base/client_config.rs (1)
rocketmq-remoting/src/protocol/namespace_util.rs (1)
  • without_namespace_with_namespace (50-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build & Test (windows-latest)
  • GitHub Check: Build & Test (ubuntu-latest)
  • GitHub Check: Code Coverage
  • GitHub Check: Build & Test (macos-latest)
  • GitHub Check: auto-approve
🔇 Additional comments (4)
rocketmq-client/src/base/client_config.rs (4)

66-67: LGTM!

The new configuration fields trace_msg_batch_num and max_page_size_in_get_metadata are appropriately typed and follow the existing naming conventions.


128-140: LGTM!

The explicit .parse::<bool>().unwrap_or(false) pattern is now consistent with other boolean environment variable parsing in this file (e.g., decode_read_body, vip_channel_enabled). The default values for the new fields are reasonable.


246-537: LGTM!

The comprehensive getters and setters are consistently implemented with proper #[inline] annotations. The set_namespace method correctly updates namespace_initialized to true (line 286), maintaining state consistency.


593-638: LGTM!

The Display implementation correctly includes all fields, including the newly added trace_msg_batch_num and max_page_size_in_get_metadata.

Comment on lines +547 to +579
pub fn reset_client_config(&mut self, other: &ClientConfig) {
self.namesrv_addr = other.namesrv_addr.clone();
self.client_ip = other.client_ip.clone();
self.instance_name = other.instance_name.clone();
self.client_callback_executor_threads = other.client_callback_executor_threads;
self.namespace = other.namespace.clone();
self.namespace_v2 = other.namespace_v2.clone();
self.access_channel = other.access_channel;
self.poll_name_server_interval = other.poll_name_server_interval;
self.heartbeat_broker_interval = other.heartbeat_broker_interval;
self.persist_consumer_offset_interval = other.persist_consumer_offset_interval;
self.pull_time_delay_millis_when_exception = other.pull_time_delay_millis_when_exception;
self.unit_mode = other.unit_mode;
self.unit_name = other.unit_name.clone();
self.decode_read_body = other.decode_read_body;
self.decode_decompress_body = other.decode_decompress_body;
self.vip_channel_enabled = other.vip_channel_enabled;
self.use_heartbeat_v2 = other.use_heartbeat_v2;
self.use_tls = other.use_tls;
self.socks_proxy_config = other.socks_proxy_config.clone();
self.language = other.language;
self.mq_client_api_timeout = other.mq_client_api_timeout;
self.detect_timeout = other.detect_timeout;
self.detect_interval = other.detect_interval;
self.enable_stream_request_type = other.enable_stream_request_type;
self.send_latency_enable = other.send_latency_enable;
self.start_detector_enable = other.start_detector_enable;
self.enable_heartbeat_channel_event_listener = other.enable_heartbeat_channel_event_listener;
self.enable_trace = other.enable_trace;
self.trace_topic = other.trace_topic.clone();
self.trace_msg_batch_num = other.trace_msg_batch_num;
self.max_page_size_in_get_metadata = other.max_page_size_in_get_metadata;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

namespace_initialized is not reset, which may cause inconsistent state.

The reset_client_config method copies all fields except namespace_initialized. If other.namespace has a value but self.namespace_initialized remains false, subsequent calls to get_namespace() may re-parse and overwrite the copied namespace.

🔎 Suggested fix
         self.namespace = other.namespace.clone();
+        self.namespace_initialized
+            .store(other.namespace_initialized.load(Ordering::Acquire), Ordering::Release);
         self.namespace_v2 = other.namespace_v2.clone();
🤖 Prompt for AI Agents
In rocketmq-client/src/base/client_config.rs around lines 547 to 579,
reset_client_config copies all fields from other but omits
namespace_initialized, which can leave self in an inconsistent state (causing
get_namespace to re-parse/overwrite the copied namespace); update the method to
also assign self.namespace_initialized = other.namespace_initialized so the
initialized flag mirrors the source and prevents redundant re-parsing.

Comment on lines +581 to +590
/// Deprecated: Use with_namespace instead
#[inline]
#[deprecated(note = "Use with_namespace for namespace wrapping")]
pub fn without_namespace(&mut self, resource: &str) -> CheetahString {
if let Some(namespace) = self.get_namespace().as_deref() {
NamespaceUtil::without_namespace_with_namespace(resource, namespace).into()
} else {
NamespaceUtil::without_namespace(resource).into()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Deprecation note is misleading.

The without_namespace method removes the namespace prefix from a resource, while with_namespace adds a namespace prefix. Suggesting with_namespace as a replacement is incorrect—they perform opposite operations. Either provide the correct alternative or clarify the intended migration path.

🤖 Prompt for AI Agents
In rocketmq-client/src/base/client_config.rs around lines 581 to 590, the
deprecation note on the without_namespace method is incorrect (it points to
with_namespace, which does the opposite); update the deprecation annotation and
message to point to the correct replacement(s) — either
NamespaceUtil::without_namespace or
NamespaceUtil::without_namespace_with_namespace depending on the desired
overload — so the note accurately directs callers to the function that removes
namespace prefixes.

@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

❌ Patch coverage is 3.37553% with 229 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.10%. Comparing base (564ec23) to head (efc2aae).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
rocketmq-client/src/base/client_config.rs 3.37% 229 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5365      +/-   ##
==========================================
- Coverage   37.17%   37.10%   -0.08%     
==========================================
  Files         800      800              
  Lines      108077   108308     +231     
==========================================
+ Hits        40182    40187       +5     
- Misses      67895    68121     +226     

☔ 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 - All CI checks passed ✅

@rocketmq-rust-bot rocketmq-rust-bot merged commit 5ceb282 into main Jan 2, 2026
18 of 20 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 Jan 2, 2026
@mxsm mxsm deleted the enh-5364 branch January 4, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement✨] Enhance ClientConfig with new trace and metadata pagination settings

4 participants