[ISSUE #3503]🚀Implement General HA components and complete AutoSwitch HA implementation✨#3504
[ISSUE #3503]🚀Implement General HA components and complete AutoSwitch HA implementation✨#3504rocketmq-rust-bot merged 1 commit intomainfrom
Conversation
… HA implementation✨
WalkthroughThis change introduces new general and AutoSwitch High Availability (HA) components, including unified client and connection managers, and expands module declarations for better organization. It adds struct definitions and trait stubs for AutoSwitch HA, updates initialization logic for DefaultHAService, and ensures proper service integration and modular separation for HA strategies. Changes
Sequence Diagram(s)sequenceDiagram
participant Config
participant GeneralHAService
participant DefaultHAService
participant AutoSwitchHAClient
participant GeneralHAClient
Config->>GeneralHAService: Provide configuration
GeneralHAService->>DefaultHAService: init(message_store)
DefaultHAService-->>GeneralHAService: Result (HAResult<()>)
GeneralHAService-->>Config: Service ready
Note over GeneralHAClient,AutoSwitchHAClient: GeneralHAClient manages DefaultHAClient and AutoSwitchHAClient based on mode
Assessment against linked issues
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
|
🔊@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💥. |
There was a problem hiding this comment.
Pull Request Overview
This PR implements general HA components and completes the AutoSwitch HA implementation to address issue #3503. Key changes include initializing DefaultHAService with an init method, introducing GeneralHAConnection and GeneralHAClient modules, and integrating new auto switch modules into the HA namespace.
- Introduces initialization for DefaultHAService by calling init with a message store.
- Adds new modules for general HA connection and client functionalities.
- Integrates auto switch HA components into the overall HA module.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rocketmq-store/src/ha/general_ha_service.rs | Updates DefaultHAService initialization with an init call. |
| rocketmq-store/src/ha/general_ha_connection.rs | Adds a new structure for general HA connection handling. |
| rocketmq-store/src/ha/general_ha_client.rs | Introduces a new structure for general HA client handling. |
| rocketmq-store/src/ha/default_ha_service.rs | Adds an empty init method to DefaultHAService for future details. |
| rocketmq-store/src/ha/auto_switch/auto_switch_ha_connection.rs | Introduces the AutoSwitchHAConnection struct. |
| rocketmq-store/src/ha/auto_switch/auto_switch_ha_client.rs | Implements an AutoSwitchHAClient with todo!() placeholders. |
| rocketmq-store/src/ha/auto_switch.rs | Adds module declarations for auto switch HA features. |
| rocketmq-store/src/ha.rs | Integrates the new general HA modules into the HA namespace. |
Comments suppressed due to low confidence (1)
rocketmq-store/src/ha/default_ha_service.rs:66
- Consider adding a comment to clarify that the init function is a stub and highlight the intended initialization steps for DefaultHAService to improve maintainability.
pub(crate) fn init(&mut self, message_store: ArcMut<LocalFileMessageStore>) -> HAResult<()> {
| todo!() | ||
| } | ||
|
|
||
| async fn shutdown(&self) { | ||
| todo!() |
There was a problem hiding this comment.
Multiple functions currently use todo!(); please ensure that these stubs are properly implemented before production deployment to avoid runtime panics.
| todo!() | |
| } | |
| async fn shutdown(&self) { | |
| todo!() | |
| // Initialize the client, e.g., set up connections or resources. | |
| println!("AutoSwitchHAClient started."); | |
| } | |
| async fn shutdown(&self) { | |
| // Release resources and close connections. | |
| println!("AutoSwitchHAClient shut down."); |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3504 +/- ##
==========================================
- Coverage 26.28% 26.27% -0.02%
==========================================
Files 550 551 +1
Lines 78341 78372 +31
==========================================
Hits 20593 20593
- Misses 57748 57779 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (4)
rocketmq-store/src/ha/auto_switch/auto_switch_ha_connection.rs (1)
17-17: Complete the AutoSwitchHAConnection implementation.This appears to be a stub implementation. The struct lacks fields, methods, and trait implementations needed for HA connection functionality.
Would you like me to help design the structure based on existing HA connection patterns in the codebase, or should this be tracked as a TODO for future implementation?
rocketmq-store/src/ha/default_ha_service.rs (2)
17-32: Remove duplicate license header.There are duplicate Apache License headers in this file (lines 1-16 and 17-32). Please remove the duplicate.
-/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */
66-69: Implement the init method functionality.The
initmethod is currently a placeholder. Consider implementing the actual initialization logic or documenting the expected behavior.Would you like me to help design the initialization logic based on the message store parameter and HA service requirements?
rocketmq-store/src/ha/general_ha_connection.rs (1)
21-24: Consider adding documentation and common trait implementations.The struct lacks documentation explaining its purpose and when to use each connection type. Also consider implementing common traits for better usability.
+/// General HA connection that can hold either a default or auto-switch HA connection. +/// This allows for flexible HA strategies within the RocketMQ store. +#[derive(Debug, Clone)] pub struct GeneralHAConnection { default_ha_connection: Option<DefaultHAConnection>, auto_switch_ha_connection: Option<AutoSwitchHAConnection>, }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
rocketmq-store/src/ha.rs(1 hunks)rocketmq-store/src/ha/auto_switch.rs(1 hunks)rocketmq-store/src/ha/auto_switch/auto_switch_ha_client.rs(1 hunks)rocketmq-store/src/ha/auto_switch/auto_switch_ha_connection.rs(1 hunks)rocketmq-store/src/ha/default_ha_service.rs(2 hunks)rocketmq-store/src/ha/general_ha_client.rs(1 hunks)rocketmq-store/src/ha/general_ha_connection.rs(1 hunks)rocketmq-store/src/ha/general_ha_service.rs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: build
- GitHub Check: auto-approve
- GitHub Check: build (ubuntu-latest, stable)
- GitHub Check: build (windows-latest, stable)
- GitHub Check: build (windows-latest, nightly)
- GitHub Check: build (macos-latest, nightly)
- GitHub Check: build (ubuntu-latest, nightly)
- GitHub Check: build (macos-latest, stable)
- GitHub Check: test
🔇 Additional comments (3)
rocketmq-store/src/ha.rs (1)
23-24: LGTM! Clean module organization.The new module declarations follow the existing pattern and use appropriate visibility for internal crate access.
rocketmq-store/src/ha/auto_switch.rs (1)
17-18: Good architectural organization.The new module declarations complete the auto-switch HA component trio (service, client, connection) and follow consistent naming conventions.
rocketmq-store/src/ha/general_ha_service.rs (1)
52-54: Excellent initialization pattern.The updated initialization logic properly creates a mutable instance, initializes it with error handling, and only assigns after successful initialization. This follows good initialization practices.
| pub struct GeneralHAConnection { | ||
| default_ha_connection: Option<DefaultHAConnection>, | ||
| auto_switch_ha_connection: Option<AutoSwitchHAConnection>, | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add constructor methods and accessor functions for the struct.
The GeneralHAConnection struct currently has private fields with no way to construct or access them. Consider adding constructor methods and accessors to make the struct usable.
pub struct GeneralHAConnection {
default_ha_connection: Option<DefaultHAConnection>,
auto_switch_ha_connection: Option<AutoSwitchHAConnection>,
}
+
+impl GeneralHAConnection {
+ pub fn new() -> Self {
+ Self {
+ default_ha_connection: None,
+ auto_switch_ha_connection: None,
+ }
+ }
+
+ pub fn with_default(connection: DefaultHAConnection) -> Self {
+ Self {
+ default_ha_connection: Some(connection),
+ auto_switch_ha_connection: None,
+ }
+ }
+
+ pub fn with_auto_switch(connection: AutoSwitchHAConnection) -> Self {
+ Self {
+ default_ha_connection: None,
+ auto_switch_ha_connection: Some(connection),
+ }
+ }
+
+ pub fn get_default_connection(&self) -> Option<&DefaultHAConnection> {
+ self.default_ha_connection.as_ref()
+ }
+
+ pub fn get_auto_switch_connection(&self) -> Option<&AutoSwitchHAConnection> {
+ self.auto_switch_ha_connection.as_ref()
+ }
+}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub struct GeneralHAConnection { | |
| default_ha_connection: Option<DefaultHAConnection>, | |
| auto_switch_ha_connection: Option<AutoSwitchHAConnection>, | |
| } | |
| pub struct GeneralHAConnection { | |
| default_ha_connection: Option<DefaultHAConnection>, | |
| auto_switch_ha_connection: Option<AutoSwitchHAConnection>, | |
| } | |
| impl GeneralHAConnection { | |
| pub fn new() -> Self { | |
| Self { | |
| default_ha_connection: None, | |
| auto_switch_ha_connection: None, | |
| } | |
| } | |
| pub fn with_default(connection: DefaultHAConnection) -> Self { | |
| Self { | |
| default_ha_connection: Some(connection), | |
| auto_switch_ha_connection: None, | |
| } | |
| } | |
| pub fn with_auto_switch(connection: AutoSwitchHAConnection) -> Self { | |
| Self { | |
| default_ha_connection: None, | |
| auto_switch_ha_connection: Some(connection), | |
| } | |
| } | |
| pub fn get_default_connection(&self) -> Option<&DefaultHAConnection> { | |
| self.default_ha_connection.as_ref() | |
| } | |
| pub fn get_auto_switch_connection(&self) -> Option<&AutoSwitchHAConnection> { | |
| self.auto_switch_ha_connection.as_ref() | |
| } | |
| } |
🤖 Prompt for AI Agents
In rocketmq-store/src/ha/general_ha_connection.rs around lines 21 to 24, the
GeneralHAConnection struct has private fields without any constructor or
accessor methods. Add a constructor method (e.g., new) to initialize the struct
with given DefaultHAConnection and AutoSwitchHAConnection options, and implement
getter methods to access these private fields safely from outside the struct.
| default_ha_service: Option<DefaultHAClient>, | ||
| auto_switch_ha_service: Option<AutoSwitchHAClient>, |
There was a problem hiding this comment.
Fix naming inconsistency between field names and types.
The field names use "service" suffix but the types are "Client" types. This creates confusion and should be corrected for consistency.
pub struct GeneralHAClient {
- default_ha_service: Option<DefaultHAClient>,
- auto_switch_ha_service: Option<AutoSwitchHAClient>,
+ default_ha_client: Option<DefaultHAClient>,
+ auto_switch_ha_client: Option<AutoSwitchHAClient>,
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| default_ha_service: Option<DefaultHAClient>, | |
| auto_switch_ha_service: Option<AutoSwitchHAClient>, | |
| pub struct GeneralHAClient { | |
| default_ha_client: Option<DefaultHAClient>, | |
| auto_switch_ha_client: Option<AutoSwitchHAClient>, | |
| } |
🤖 Prompt for AI Agents
In rocketmq-store/src/ha/general_ha_client.rs around lines 22 to 23, the field
names use the suffix "service" while their types use "Client," causing
inconsistency. Rename the fields from default_ha_service and
auto_switch_ha_service to default_ha_client and auto_switch_ha_client
respectively to match the type names and maintain clear, consistent naming.
| pub struct GeneralHAClient { | ||
| default_ha_service: Option<DefaultHAClient>, | ||
| auto_switch_ha_service: Option<AutoSwitchHAClient>, | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add constructor methods and accessor functions for the struct.
Similar to GeneralHAConnection, this struct needs constructor methods and accessors to be usable. The implementation pattern should be consistent across both general HA structs.
pub struct GeneralHAClient {
- default_ha_service: Option<DefaultHAClient>,
- auto_switch_ha_service: Option<AutoSwitchHAClient>,
+ default_ha_client: Option<DefaultHAClient>,
+ auto_switch_ha_client: Option<AutoSwitchHAClient>,
}
+
+impl GeneralHAClient {
+ pub fn new() -> Self {
+ Self {
+ default_ha_client: None,
+ auto_switch_ha_client: None,
+ }
+ }
+
+ pub fn with_default(client: DefaultHAClient) -> Self {
+ Self {
+ default_ha_client: Some(client),
+ auto_switch_ha_client: None,
+ }
+ }
+
+ pub fn with_auto_switch(client: AutoSwitchHAClient) -> Self {
+ Self {
+ default_ha_client: None,
+ auto_switch_ha_client: Some(client),
+ }
+ }
+
+ pub fn get_default_client(&self) -> Option<&DefaultHAClient> {
+ self.default_ha_client.as_ref()
+ }
+
+ pub fn get_auto_switch_client(&self) -> Option<&AutoSwitchHAClient> {
+ self.auto_switch_ha_client.as_ref()
+ }
+}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub struct GeneralHAClient { | |
| default_ha_service: Option<DefaultHAClient>, | |
| auto_switch_ha_service: Option<AutoSwitchHAClient>, | |
| } | |
| pub struct GeneralHAClient { | |
| default_ha_client: Option<DefaultHAClient>, | |
| auto_switch_ha_client: Option<AutoSwitchHAClient>, | |
| } | |
| impl GeneralHAClient { | |
| /// Creates an empty client with no HA backends configured. | |
| pub fn new() -> Self { | |
| Self { | |
| default_ha_client: None, | |
| auto_switch_ha_client: None, | |
| } | |
| } | |
| /// Creates a client using the given `DefaultHAClient`. | |
| pub fn with_default(client: DefaultHAClient) -> Self { | |
| Self { | |
| default_ha_client: Some(client), | |
| auto_switch_ha_client: None, | |
| } | |
| } | |
| /// Creates a client using the given `AutoSwitchHAClient`. | |
| pub fn with_auto_switch(client: AutoSwitchHAClient) -> Self { | |
| Self { | |
| default_ha_client: None, | |
| auto_switch_ha_client: Some(client), | |
| } | |
| } | |
| /// Returns a reference to the default HA client, if configured. | |
| pub fn get_default_client(&self) -> Option<&DefaultHAClient> { | |
| self.default_ha_client.as_ref() | |
| } | |
| /// Returns a reference to the auto‐switch HA client, if configured. | |
| pub fn get_auto_switch_client(&self) -> Option<&AutoSwitchHAClient> { | |
| self.auto_switch_ha_client.as_ref() | |
| } | |
| } |
🤖 Prompt for AI Agents
In rocketmq-store/src/ha/general_ha_client.rs around lines 21 to 24, the
GeneralHAClient struct lacks constructor methods and accessor functions, which
are necessary for consistent usage similar to GeneralHAConnection. Add a
constructor method to initialize GeneralHAClient with appropriate parameters and
implement accessor functions to retrieve references to default_ha_service and
auto_switch_ha_service fields, following the pattern used in GeneralHAConnection
for consistency.
| impl HAClient for AutoSwitchHAClient { | ||
| async fn start(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn shutdown(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn wakeup(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn update_master_address(&self, new_address: &str) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn update_ha_master_address(&self, new_address: &str) { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_master_address(&self) -> String { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_ha_master_address(&self) -> String { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_last_read_timestamp(&self) -> i64 { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_last_write_timestamp(&self) -> i64 { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_current_state(&self) -> HAConnectionState { | ||
| todo!() | ||
| } | ||
|
|
||
| fn change_current_state(&self, ha_connection_state: HAConnectionState) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn close_master(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_transferred_byte_in_second(&self) -> i64 { | ||
| todo!() | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add documentation explaining the AutoSwitch HA strategy.
The implementation lacks documentation explaining how the AutoSwitch HA client differs from the default HA client and what auto-switching behavior it should provide.
+/// AutoSwitch HA Client that automatically switches between master nodes
+/// based on availability and performance metrics.
+///
+/// This client implements intelligent failover logic to ensure high availability
+/// of the RocketMQ broker by monitoring connection health and switching to
+/// backup masters when the primary master becomes unavailable.
pub struct AutoSwitchHAClient {
// ... fields
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In rocketmq-store/src/ha/auto_switch/auto_switch_ha_client.rs between lines 23
and 75, add documentation comments to the AutoSwitchHAClient implementation.
Explain the purpose of the AutoSwitch HA client, how it differs from the default
HA client, and describe the auto-switching behavior it provides. Place these
comments above the impl block or each method as appropriate to clarify the
design and functionality for future maintainers.
| use crate::ha::ha_client::HAClient; | ||
| use crate::ha::ha_connection_state::HAConnectionState; | ||
|
|
||
| pub struct AutoSwitchHAClient; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add internal fields to support HA client functionality.
The AutoSwitchHAClient struct is currently empty but needs internal state to manage HA operations like master addresses, connection state, timestamps, etc.
+use std::sync::{Arc, Mutex};
+
-pub struct AutoSwitchHAClient;
+pub struct AutoSwitchHAClient {
+ master_address: Arc<Mutex<String>>,
+ ha_master_address: Arc<Mutex<String>>,
+ last_read_timestamp: Arc<Mutex<i64>>,
+ last_write_timestamp: Arc<Mutex<i64>>,
+ current_state: Arc<Mutex<HAConnectionState>>,
+ transferred_bytes: Arc<Mutex<i64>>,
+}
+
+impl AutoSwitchHAClient {
+ pub fn new() -> Self {
+ Self {
+ master_address: Arc::new(Mutex::new(String::new())),
+ ha_master_address: Arc::new(Mutex::new(String::new())),
+ last_read_timestamp: Arc::new(Mutex::new(0)),
+ last_write_timestamp: Arc::new(Mutex::new(0)),
+ current_state: Arc::new(Mutex::new(HAConnectionState::default())),
+ transferred_bytes: Arc::new(Mutex::new(0)),
+ }
+ }
+}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub struct AutoSwitchHAClient; | |
| use crate::ha_client::{HAClient, HAConnectionState}; | |
| use std::sync::{Arc, Mutex}; | |
| pub struct AutoSwitchHAClient { | |
| master_address: Arc<Mutex<String>>, | |
| ha_master_address: Arc<Mutex<String>>, | |
| last_read_timestamp: Arc<Mutex<i64>>, | |
| last_write_timestamp: Arc<Mutex<i64>>, | |
| current_state: Arc<Mutex<HAConnectionState>>, | |
| transferred_bytes: Arc<Mutex<i64>>, | |
| } | |
| impl AutoSwitchHAClient { | |
| pub fn new() -> Self { | |
| Self { | |
| master_address: Arc::new(Mutex::new(String::new())), | |
| ha_master_address: Arc::new(Mutex::new(String::new())), | |
| last_read_timestamp: Arc::new(Mutex::new(0)), | |
| last_write_timestamp: Arc::new(Mutex::new(0)), | |
| current_state: Arc::new(Mutex::new(HAConnectionState::default())), | |
| transferred_bytes: Arc::new(Mutex::new(0)), | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
In rocketmq-store/src/ha/auto_switch/auto_switch_ha_client.rs at line 21, the
AutoSwitchHAClient struct is empty and lacks the necessary internal fields to
manage HA client functionality. Add fields such as master addresses, connection
state, and timestamps to this struct to properly support HA operations and
maintain internal state.
| async fn start(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn shutdown(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn wakeup(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn update_master_address(&self, new_address: &str) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn update_ha_master_address(&self, new_address: &str) { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_master_address(&self) -> String { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_ha_master_address(&self) -> String { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_last_read_timestamp(&self) -> i64 { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_last_write_timestamp(&self) -> i64 { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_current_state(&self) -> HAConnectionState { | ||
| todo!() | ||
| } | ||
|
|
||
| fn change_current_state(&self, ha_connection_state: HAConnectionState) { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn close_master(&self) { | ||
| todo!() | ||
| } | ||
|
|
||
| fn get_transferred_byte_in_second(&self) -> i64 { | ||
| todo!() | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Replace todo!() stubs with basic implementations to prevent runtime panics.
All methods currently use todo!() which will panic if called. Consider implementing basic functionality or at least safe defaults to make the code usable during development.
Here's an example of implementing some basic methods:
impl HAClient for AutoSwitchHAClient {
async fn start(&self) {
- todo!()
+ // TODO: Implement AutoSwitch HA client startup logic
+ println!("AutoSwitchHAClient: start() called");
}
async fn shutdown(&self) {
- todo!()
+ // TODO: Implement AutoSwitch HA client shutdown logic
+ println!("AutoSwitchHAClient: shutdown() called");
}
fn get_master_address(&self) -> String {
- todo!()
+ self.master_address.lock().unwrap().clone()
}
fn get_ha_master_address(&self) -> String {
- todo!()
+ self.ha_master_address.lock().unwrap().clone()
}
fn get_last_read_timestamp(&self) -> i64 {
- todo!()
+ *self.last_read_timestamp.lock().unwrap()
}
fn get_last_write_timestamp(&self) -> i64 {
- todo!()
+ *self.last_write_timestamp.lock().unwrap()
}
fn get_current_state(&self) -> HAConnectionState {
- todo!()
+ *self.current_state.lock().unwrap()
}🤖 Prompt for AI Agents
In rocketmq-store/src/ha/auto_switch/auto_switch_ha_client.rs between lines 24
and 75, all methods currently use todo!() which causes runtime panics if called.
Replace these todo!() stubs with basic implementations or safe default returns
to prevent panics during development. For async methods, provide minimal async
blocks that do nothing or log a placeholder; for getters, return default values
like empty strings or zero; for state-related methods, return a default
HAConnectionState or update an internal state variable accordingly. This will
make the code safe to call and easier to extend later.
Which Issue(s) This PR Fixes(Closes)
Fixes #3503
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
Refactor
Chores