From d3a84395dc22cc4406b29790dfeec8c4fc62eccb Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Tue, 30 Jun 2026 02:09:14 +0800 Subject: [PATCH] refactor(replication): add msgp boundary (#4076) --- crates/ecstore/src/bucket/replication/mod.rs | 1 + .../replication/replication_msgp_boundary.rs | 15 +++++++++++++++ .../bucket/replication/replication_resyncer.rs | 3 +-- scripts/check_architecture_migration_rules.sh | 13 +++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 crates/ecstore/src/bucket/replication/replication_msgp_boundary.rs diff --git a/crates/ecstore/src/bucket/replication/mod.rs b/crates/ecstore/src/bucket/replication/mod.rs index c46edbf7d..1b662cd17 100644 --- a/crates/ecstore/src/bucket/replication/mod.rs +++ b/crates/ecstore/src/bucket/replication/mod.rs @@ -18,6 +18,7 @@ mod replication_config_store; mod replication_event_sink; mod replication_lock_boundary; mod replication_metadata_boundary; +mod replication_msgp_boundary; mod replication_pool; mod replication_resyncer; mod replication_state; diff --git a/crates/ecstore/src/bucket/replication/replication_msgp_boundary.rs b/crates/ecstore/src/bucket/replication/replication_msgp_boundary.rs new file mode 100644 index 000000000..9d9362843 --- /dev/null +++ b/crates/ecstore/src/bucket/replication/replication_msgp_boundary.rs @@ -0,0 +1,15 @@ +// Copyright 2024 RustFS Team +// +// Licensed 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. + +pub(crate) use crate::bucket::msgp_decode::{read_msgp_ext8_time, skip_msgp_value, write_msgp_time}; diff --git a/crates/ecstore/src/bucket/replication/replication_resyncer.rs b/crates/ecstore/src/bucket/replication/replication_resyncer.rs index 3907f360b..c42427113 100644 --- a/crates/ecstore/src/bucket/replication/replication_resyncer.rs +++ b/crates/ecstore/src/bucket/replication/replication_resyncer.rs @@ -16,6 +16,7 @@ use super::replication_config_store as config_store; use super::replication_event_sink::{EventArgs, send_event}; use super::replication_lock_boundary as lock_boundary; use super::replication_metadata_boundary as metadata_boundary; +use super::replication_msgp_boundary::{read_msgp_ext8_time, skip_msgp_value, write_msgp_time}; use super::replication_target_boundary as target_boundary; use super::replication_versioning_boundary as versioning_boundary; use super::runtime_boundary as runtime_sources; @@ -23,7 +24,6 @@ use crate::bucket::bandwidth::reader::{BucketOptions, MonitorReaderOptions, Moni use crate::bucket::bucket_target_sys::{ AdvancedPutOptions, PutObjectOptions, PutObjectPartOptions, RemoveObjectOptions, TargetClient, }; -use crate::bucket::msgp_decode::{read_msgp_ext8_time, skip_msgp_value, write_msgp_time}; use crate::bucket::replication::ResyncStatusType; use crate::bucket::replication::{ObjectOpts, ReplicationConfigurationExt as _}; use crate::bucket::tagging::decode_tags_to_map; @@ -4201,7 +4201,6 @@ fn get_replication_action(oi1: &ObjectInfo, oi2: &HeadObjectOutput, op_type: Rep #[cfg(test)] mod tests { use super::*; - use crate::bucket::msgp_decode::write_msgp_time; use std::collections::HashMap; use time::OffsetDateTime; use uuid::Uuid; diff --git a/scripts/check_architecture_migration_rules.sh b/scripts/check_architecture_migration_rules.sh index b3dffb0e1..718923115 100755 --- a/scripts/check_architecture_migration_rules.sh +++ b/scripts/check_architecture_migration_rules.sh @@ -187,6 +187,7 @@ REPLICATION_CONFIG_STORE_BYPASS_HITS_FILE="${TMP_DIR}/replication_config_store_b REPLICATION_EVENT_SINK_BYPASS_HITS_FILE="${TMP_DIR}/replication_event_sink_bypass_hits.txt" REPLICATION_LOCK_BOUNDARY_BYPASS_HITS_FILE="${TMP_DIR}/replication_lock_boundary_bypass_hits.txt" REPLICATION_METADATA_BOUNDARY_BYPASS_HITS_FILE="${TMP_DIR}/replication_metadata_boundary_bypass_hits.txt" +REPLICATION_MSGP_BOUNDARY_BYPASS_HITS_FILE="${TMP_DIR}/replication_msgp_boundary_bypass_hits.txt" REPLICATION_TARGET_BOUNDARY_BYPASS_HITS_FILE="${TMP_DIR}/replication_target_boundary_bypass_hits.txt" REPLICATION_VERSIONING_BOUNDARY_BYPASS_HITS_FILE="${TMP_DIR}/replication_versioning_boundary_bypass_hits.txt" REPLICATION_RUNTIME_SOURCE_BYPASS_HITS_FILE="${TMP_DIR}/replication_runtime_source_bypass_hits.txt" @@ -2380,6 +2381,18 @@ if [[ -s "$REPLICATION_LOCK_BOUNDARY_BYPASS_HITS_FILE" ]]; then report_failure "replication lock timeout access must stay behind replication lock boundary: $(paste -sd '; ' "$REPLICATION_LOCK_BOUNDARY_BYPASS_HITS_FILE")" fi +( + cd "$ROOT_DIR" + rg -n --with-filename 'crate::bucket::msgp_decode' \ + crates/ecstore/src/bucket/replication \ + --glob '*.rs' | + rg -v '^crates/ecstore/src/bucket/replication/replication_msgp_boundary\.rs:' || true +) >"$REPLICATION_MSGP_BOUNDARY_BYPASS_HITS_FILE" + +if [[ -s "$REPLICATION_MSGP_BOUNDARY_BYPASS_HITS_FILE" ]]; then + report_failure "replication msgp helpers must stay behind replication msgp boundary: $(paste -sd '; ' "$REPLICATION_MSGP_BOUNDARY_BYPASS_HITS_FILE")" +fi + ( cd "$ROOT_DIR" rg -n --with-filename 'BucketTargetSys::get\(\)' \