mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
refactor(ecstore): route replication config access (#4128)
This commit is contained in:
@@ -12,7 +12,7 @@ and lifecycle/heal scheduling paths.
|
||||
| `config.rs` | Replication config helpers, rule matching, and tag filtering. | Uses replication-local filemeta/tagging boundaries and S3 DTOs directly. |
|
||||
| `datatypes.rs` | Replication status and operation DTOs. | Publicly re-exported through the ECStore replication facade. |
|
||||
| `replication_pool.rs` | Replication queue, worker pool, MRF persistence, bucket stats, and delete/object scheduling. | Depends on bucket target sys, bucket metadata sys, metadata paths, and file metadata replication contracts through local boundaries, config storage, storage contracts through the replication storage boundary, runtime sources, and notification state. |
|
||||
| `replication_resyncer.rs` | Object replication, delete replication, resync, MRF encode/decode, target calls, and multipart target upload paths. | Depends on target calls and target config types through the replication target boundary, metadata paths and metadata systems through the replication metadata boundary, file metadata replication contracts through the filemeta boundary, error contracts through the error boundary, versioning systems, storage contracts through the replication storage boundary, runtime sources, notification events and local event host selection through the event sink, bandwidth reader wrapping, and SetDisks lock timing. |
|
||||
| `replication_resyncer.rs` | Object replication, delete replication, resync, MRF encode/decode, target calls, and multipart target upload paths. | Depends on target calls and target config types through the replication target boundary, metadata paths and metadata systems through the replication metadata boundary, file metadata replication contracts through the filemeta boundary, error contracts through the error boundary, versioning systems, storage contracts through the replication storage boundary, config-derived storage class labels through the config store, runtime sources, notification events and local event host selection through the event sink, bandwidth reader wrapping, and SetDisks lock timing. |
|
||||
| `replication_state.rs` | Replication queue/stat state and worker accounting. | Reads runtime sources, file metadata replication contracts, and error contracts through local boundaries, and owns shared replication pool/stat state. |
|
||||
| `rule.rs` | Rule evaluation helpers for object replication options. | Depends on ECStore replication object option types. |
|
||||
| `mod.rs` | Compatibility re-export facade for the current ECStore owner. | Must stay stable until downstream scanner, lifecycle, heal, and metrics paths compile through replacement contracts. |
|
||||
@@ -24,6 +24,7 @@ and lifecycle/heal scheduling paths.
|
||||
| `ReplicationObjectIO` | Object read/write primitives used by config, MRF, resync status, and multipart replication paths. | ECStore object API reader/writer types and storage-api object IO contracts are concentrated in `replication_storage_boundary.rs`. |
|
||||
| `ReplicationStorage` | Object read/write/delete, object walk, metadata update, and target object IO. | ECStore object API, storage-api contracts, and read option types are concentrated in `replication_storage_boundary.rs`. |
|
||||
| `ReplicationMetadataStore` | Replication config, MRF/resync state, target reset headers, and status persistence. | Metadata sys access and replication metadata path constants are concentrated in `replication_metadata_boundary.rs`; versioning sys and config storage imports remain. |
|
||||
| `ReplicationConfigStore` | Replication config persistence and config-derived labels used by target options. | Config read/save helpers and storage class labels are concentrated in `replication_config_store.rs`. |
|
||||
| `ReplicationFileMeta` | Replication status, decisions, MRF entries, resync decisions, and target reset helpers. | `rustfs_filemeta` replication contracts are concentrated in `replication_filemeta_boundary.rs`; `FileInfo` remains in the storage boundary for storage trait bindings and walk options. |
|
||||
| `ReplicationErrorBoundary` | ECStore error/result contracts and replication-specific error classifiers. | `crate::error` imports are concentrated in `replication_error_boundary.rs`. |
|
||||
| `ReplicationTargetStore` | Bucket target listing, target client lookup, target offline checks, target config types, and target operation option types. | Bucket target sys access, `BucketTargets`, and target operation types are concentrated in `replication_target_boundary.rs`. |
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
use super::replication_error_boundary::Result;
|
||||
use super::replication_storage_boundary::ReplicationObjectIO;
|
||||
use crate::config::com;
|
||||
pub(crate) use crate::config::storageclass::{RRS, STANDARD};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) async fn read<S>(api: Arc<S>, file: &str) -> Result<Vec<u8>>
|
||||
|
||||
@@ -3660,7 +3660,6 @@ fn is_valid_sse_header(k: &str) -> Option<&str> {
|
||||
}
|
||||
|
||||
fn put_replication_opts(sc: &str, object_info: &ObjectInfo) -> Result<(PutObjectOptions, bool)> {
|
||||
use crate::config::storageclass::{RRS, STANDARD};
|
||||
use base64::{Engine, engine::general_purpose::STANDARD as BASE64_STANDARD};
|
||||
use rustfs_utils::http::{
|
||||
AMZ_CHECKSUM_TYPE, AMZ_CHECKSUM_TYPE_FULL_OBJECT, AMZ_SERVER_SIDE_ENCRYPTION, AMZ_SERVER_SIDE_ENCRYPTION_KMS_ID,
|
||||
@@ -3727,7 +3726,7 @@ fn put_replication_opts(sc: &str, object_info: &ObjectInfo) -> Result<(PutObject
|
||||
// Handle storage class default
|
||||
let storage_class = if sc.is_empty() {
|
||||
let obj_sc = object_info.storage_class.as_deref().unwrap_or_default();
|
||||
if obj_sc == STANDARD || obj_sc == RRS {
|
||||
if obj_sc == config_store::STANDARD || obj_sc == config_store::RRS {
|
||||
obj_sc.to_string()
|
||||
} else {
|
||||
sc.to_string()
|
||||
|
||||
@@ -104,7 +104,8 @@ Current coupling:
|
||||
- replication workers depend on `ReplicationStorage`, ECStore object APIs and
|
||||
storage-api contracts through the replication storage boundary, bucket target
|
||||
clients, bucket metadata, file metadata replication state through the
|
||||
filemeta boundary, scanner repair
|
||||
filemeta boundary, config-derived storage class labels through the config
|
||||
store, scanner repair
|
||||
classification, runtime replication pool/stat handles, bucket monitor and
|
||||
bandwidth reader access through local boundaries, local node names, and
|
||||
notification events;
|
||||
@@ -131,6 +132,10 @@ Required contracts before crate movement:
|
||||
MRF/resync state, and status persistence. Metadata sys access and replication
|
||||
metadata path constants are concentrated in
|
||||
`crates/ecstore/src/bucket/replication/replication_metadata_boundary.rs`.
|
||||
- `ReplicationConfigStore`: replication config persistence and config-derived
|
||||
labels used by target options. Config read/save helpers and storage class
|
||||
labels are concentrated in
|
||||
`crates/ecstore/src/bucket/replication/replication_config_store.rs`.
|
||||
- `ReplicationFileMeta`: replication status, decisions, MRF entries, resync
|
||||
decisions, and target reset helpers. `rustfs_filemeta` replication contracts
|
||||
are concentrated in
|
||||
|
||||
@@ -2539,14 +2539,56 @@ fi
|
||||
|
||||
(
|
||||
cd "$ROOT_DIR"
|
||||
rg -n --with-filename 'crate::config::com::\{[^}]*\b(read_config|save_config)\b|crate::config::com::(read_config|save_config)|\b(read_config|save_config)\(' \
|
||||
crates/ecstore/src/bucket/replication \
|
||||
--glob '*.rs' |
|
||||
find crates/ecstore/src/bucket/replication -type f -name '*.rs' -print0 |
|
||||
xargs -0 perl -0ne '
|
||||
sub emit_match {
|
||||
my ($pos, $match) = @_;
|
||||
my $prefix = substr($_, 0, $pos);
|
||||
my $line = ($prefix =~ tr/\n//) + 1;
|
||||
$match =~ s/\s+/ /g;
|
||||
print "$ARGV:$line:$match\n";
|
||||
}
|
||||
|
||||
while (/(?:crate::config::|use\s+crate::config\b)/sg) {
|
||||
emit_match($-[0], $&);
|
||||
}
|
||||
|
||||
while (/use\s+crate::\{([^;]*)/sg) {
|
||||
my ($pos, $end, $body) = ($-[0], $+[0], $1);
|
||||
my ($depth, $token) = (0, "");
|
||||
my $matched = 0;
|
||||
|
||||
for my $ch (split //, $body) {
|
||||
if ($ch eq "{") {
|
||||
$depth++;
|
||||
next;
|
||||
}
|
||||
if ($ch eq "}") {
|
||||
$depth-- if $depth > 0;
|
||||
next;
|
||||
}
|
||||
if ($depth == 0 && $ch eq ",") {
|
||||
if ($token =~ /^\s*config\b/s) {
|
||||
emit_match($pos, substr($_, $pos, $end - $pos));
|
||||
$matched = 1;
|
||||
last;
|
||||
}
|
||||
$token = "";
|
||||
next;
|
||||
}
|
||||
$token .= $ch if $depth == 0;
|
||||
}
|
||||
|
||||
if (!$matched && $token =~ /^\s*config\b/s) {
|
||||
emit_match($pos, substr($_, $pos, $end - $pos));
|
||||
}
|
||||
}
|
||||
' |
|
||||
rg -v '^crates/ecstore/src/bucket/replication/replication_config_store\.rs:' || true
|
||||
) >"$REPLICATION_CONFIG_STORE_BYPASS_HITS_FILE"
|
||||
|
||||
if [[ -s "$REPLICATION_CONFIG_STORE_BYPASS_HITS_FILE" ]]; then
|
||||
report_failure "replication config persistence must stay behind replication config store: $(paste -sd '; ' "$REPLICATION_CONFIG_STORE_BYPASS_HITS_FILE")"
|
||||
report_failure "replication config access must stay behind replication config store: $(paste -sd '; ' "$REPLICATION_CONFIG_STORE_BYPASS_HITS_FILE")"
|
||||
fi
|
||||
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user