refactor: consolidate ecstore public facade (#3678)

* refactor: expand ecstore compatibility facade

* test: enforce ecstore api facade imports

* refactor: hide legacy ecstore layout modules

* refactor: hide ecstore facade root modules
This commit is contained in:
安正超
2026-06-21 09:09:11 +08:00
committed by GitHub
parent 77e005ee98
commit 0985225448
32 changed files with 498 additions and 252 deletions
+95
View File
@@ -18,6 +18,17 @@ pub mod admin {
pub use crate::admin_server_info::{get_local_server_property, get_server_info};
}
pub mod bucket {
pub use crate::bucket::{
bandwidth, bucket_target_sys, lifecycle, metadata, metadata_sys, migration, object_lock, policy_sys, quota, replication,
tagging, target, utils, versioning, versioning_sys,
};
}
pub mod cache {
pub use crate::cache_value::metacache_set::{ListPathRawOptions, list_path_raw};
}
pub mod capacity {
pub use crate::pools::{
PoolDecommissionInfo, PoolStatus, get_total_usable_capacity, get_total_usable_capacity_free, path2_bucket_object,
@@ -26,6 +37,61 @@ pub mod capacity {
pub use crate::store_utils::is_reserved_or_invalid_bucket;
}
pub mod client {
pub use crate::client::{admin_handler_utils, object_api_utils, transition_api};
}
pub mod compression {
pub use crate::compress::{MIN_DISK_COMPRESSIBLE_SIZE, is_disk_compressible};
}
pub mod config {
pub use crate::config::{
RUSTFS_CONFIG_PREFIX, com, init, init_global_config_sys, set_global_storage_class, storageclass,
try_migrate_server_config,
};
}
pub mod data_usage {
pub use crate::data_usage::{
DATA_USAGE_CACHE_NAME, apply_bucket_usage_memory_overlay, load_data_usage_from_backend,
record_bucket_object_delete_memory, record_bucket_object_write_memory, replace_bucket_usage_memory_from_info,
};
}
pub mod disk {
pub use crate::disk::endpoint::Endpoint;
pub use crate::disk::error::DiskError;
pub use crate::disk::error_reduce::is_all_buckets_not_found;
pub use crate::disk::{
BUCKET_META_PREFIX, DeleteOptions, Disk, DiskAPI, DiskInfoOptions, DiskOption, DiskStore, FileInfoVersions,
RUSTFS_META_BUCKET, ReadMultipleReq, ReadMultipleResp, ReadOptions, STORAGE_FORMAT_FILE, UpdateMetadataOpts, VolumeInfo,
WalkDirOptions, new_disk,
};
pub use crate::disk::{endpoint, error, error_reduce};
}
pub mod error {
pub use crate::error::{
Error, Result, StorageError, classify_system_path_failure_reason, is_err_bucket_not_found, is_err_object_not_found,
is_err_version_not_found,
};
}
pub mod event {
pub use crate::event_notification::{EventArgs, register_event_dispatch_hook};
}
pub mod global {
pub use crate::global::{
GLOBAL_BOOT_TIME, GLOBAL_LOCAL_DISK_MAP, GLOBAL_TierConfigMgr, get_global_bucket_monitor, get_global_deployment_id,
get_global_endpoints_opt, get_global_lock_client, get_global_lock_clients, get_global_region, get_global_tier_config_mgr,
global_rustfs_port, is_dist_erasure, is_erasure, is_erasure_sd, is_first_cluster_node_local, new_object_layer_fn,
resolve_object_store_handle, set_global_endpoints, set_global_region, set_global_rustfs_port, set_object_store_resolver,
shutdown_background_services, update_erasure_type,
};
}
pub mod layout {
pub use crate::disks_layout::DisksLayout;
pub use crate::endpoints::{EndpointServerPools, Endpoints, PoolEndpoints};
@@ -41,9 +107,38 @@ pub mod notification {
};
}
pub mod rebalance {
pub use crate::rebalance::{
DiskStat, RebalSaveOpt, RebalStatus, RebalanceCleanupWarnings, RebalanceInfo, RebalanceMeta, RebalanceStats,
};
}
pub mod rio {
pub use crate::rio::{
DecryptReader, DynReader, EncryptReader, HardLimitReader, HashReader, WriteEncryption, WritePlan, boxed_reader,
compression_metadata_value, wrap_reader,
};
}
pub mod rpc {
pub use crate::rpc::{
LocalPeerS3Client, PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PeerRestClient, PeerS3Client, SERVICE_SIGNAL_REFRESH_CONFIG,
SERVICE_SIGNAL_RELOAD_DYNAMIC, TONIC_RPC_PREFIX, TonicInterceptor, gen_tonic_signature_interceptor,
node_service_time_out_client, node_service_time_out_client_no_auth, verify_rpc_signature,
};
}
pub mod set_disk {
pub use crate::set_disk::{DEFAULT_READ_BUFFER_SIZE, SetDisks, get_lock_acquire_timeout, is_valid_storage_class};
}
pub mod storage {
pub use crate::store::{
ECStore, all_local_disk, all_local_disk_path, find_local_disk_by_ref, init_local_disks, init_lock_clients,
prewarm_local_disk_id_map,
};
}
pub mod tier {
pub use crate::tier::{tier, tier_admin, tier_config, tier_handlers, warm_backend};
}
-1
View File
@@ -215,7 +215,6 @@ fn is_disk_compressible_with_config(headers: &http::HeaderMap, object_name: &str
#[cfg(test)]
mod tests {
use super::*;
use temp_env;
#[test]
fn test_parse_disk_compression_enabled() {
+2 -6
View File
@@ -21,11 +21,7 @@ use crate::{
error::{Error, classify_system_path_failure_reason},
store::ECStore,
};
pub use local_snapshot::{
DATA_USAGE_DIR, DATA_USAGE_STATE_DIR, LOCAL_USAGE_SNAPSHOT_VERSION, LocalUsageSnapshot, LocalUsageSnapshotMeta,
data_usage_dir, data_usage_state_dir, ensure_data_usage_layout, read_snapshot as read_local_snapshot, snapshot_file_name,
snapshot_object_path, snapshot_path, write_snapshot as write_local_snapshot,
};
pub use local_snapshot::{LocalUsageSnapshot, read_snapshot as read_local_snapshot, snapshot_path};
use rustfs_data_usage::{
BucketTargetUsageInfo, BucketUsageInfo, DataUsageCache, DataUsageEntry, DataUsageInfo, DiskUsageStatus, SizeSummary,
};
@@ -870,7 +866,7 @@ mod tests {
#[test]
fn aggregate_skips_corrupted_snapshot_and_preserves_other_disks() {
let mut good_snapshot = LocalUsageSnapshot::new(LocalUsageSnapshotMeta {
let mut good_snapshot = LocalUsageSnapshot::new(local_snapshot::LocalUsageSnapshotMeta {
disk_id: "good-disk".to_string(),
pool_index: Some(0),
set_index: Some(0),
+9 -9
View File
@@ -60,17 +60,17 @@ impl RuntimeDriveHealthState {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DriveRecoveryClass {
ShortOffline,
MediumOffline,
LongOffline,
Short,
Medium,
Long,
}
impl DriveRecoveryClass {
pub fn as_str(self) -> &'static str {
match self {
Self::ShortOffline => "short_offline",
Self::MediumOffline => "medium_offline",
Self::LongOffline => "long_offline",
Self::Short => "short_offline",
Self::Medium => "medium_offline",
Self::Long => "long_offline",
}
}
}
@@ -112,11 +112,11 @@ pub fn get_drive_long_offline_threshold() -> Duration {
pub fn classify_drive_recovery(duration: Duration) -> DriveRecoveryClass {
if duration <= get_drive_offline_grace_period() {
DriveRecoveryClass::ShortOffline
DriveRecoveryClass::Short
} else if duration >= get_drive_long_offline_threshold() {
DriveRecoveryClass::LongOffline
DriveRecoveryClass::Long
} else {
DriveRecoveryClass::MediumOffline
DriveRecoveryClass::Medium
}
}
+23 -23
View File
@@ -15,47 +15,47 @@
extern crate core;
pub mod admin_server_info;
mod admin_server_info;
pub mod api;
pub mod batch_processor;
pub mod bitrot;
pub mod bucket;
pub mod cache_value;
pub mod compress;
pub mod config;
mod bucket;
mod cache_value;
mod compress;
mod config;
mod data_movement;
pub mod data_usage;
pub mod disk;
pub mod disks_layout;
pub mod endpoints;
mod data_usage;
mod disk;
mod disks_layout;
mod endpoints;
pub mod erasure_coding;
pub mod error;
pub mod global;
mod error;
mod global;
pub(crate) mod layout;
pub mod metrics_realtime;
pub mod notification_sys;
mod metrics_realtime;
mod notification_sys;
pub mod object_api;
pub mod pools;
pub mod rebalance;
pub mod rio;
pub mod rpc;
pub mod set_disk;
mod pools;
mod rebalance;
mod rio;
mod rpc;
mod set_disk;
mod sets;
mod storage_api_contracts;
pub mod store;
mod store;
mod store_init;
pub mod store_list_objects;
pub mod store_utils;
mod store_utils;
// pub mod checksum;
pub mod client;
mod client;
pub mod event;
pub mod event_notification;
mod event_notification;
#[cfg(test)]
mod pools_test;
#[cfg(test)]
mod store_test;
pub mod tier;
mod tier;
pub use global::set_global_endpoints;
pub use global::update_erasure_type;
+1 -3
View File
@@ -41,9 +41,7 @@ mod runtime;
mod types;
mod worker;
pub use types::{
DiskStat, RStats, RebalSaveOpt, RebalStatus, RebalanceCleanupWarnings, RebalanceInfo, RebalanceMeta, RebalanceStats,
};
pub use types::{DiskStat, RebalSaveOpt, RebalStatus, RebalanceCleanupWarnings, RebalanceInfo, RebalanceMeta, RebalanceStats};
use types::{RebalanceBucketConfigs, RebalanceBucketOutcome, RebalanceEntryOutcome};
#[cfg(test)]
+5 -7
View File
@@ -25,14 +25,12 @@ pub use client::{
TonicInterceptor, gen_tonic_signature_interceptor, node_service_time_out_client, node_service_time_out_client_no_auth,
};
pub use http_auth::{TONIC_RPC_PREFIX, build_auth_headers, gen_signature_headers, verify_rpc_signature};
pub use internode_data_transport::{
InternodeDataTransport, InternodeDataTransportCapabilities, ReadStreamRequest, TcpHttpInternodeDataTransport,
WalkDirStreamRequest, WriteStreamRequest, build_internode_data_transport, build_internode_data_transport_from_env,
};
#[cfg(test)]
pub(crate) use internode_data_transport::TcpHttpInternodeDataTransport;
pub use internode_data_transport::build_internode_data_transport_from_env;
pub use peer_rest_client::{
PEER_RESTDRY_RUN, PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PeerRestClient, SERVICE_SIGNAL_REFRESH_CONFIG,
SERVICE_SIGNAL_RELOAD_DYNAMIC,
PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PeerRestClient, SERVICE_SIGNAL_REFRESH_CONFIG, SERVICE_SIGNAL_RELOAD_DYNAMIC,
};
pub use peer_s3_client::{LocalPeerS3Client, PeerS3Client, RemotePeerS3Client, S3PeerSys};
pub use peer_s3_client::{LocalPeerS3Client, PeerS3Client, S3PeerSys};
pub use remote_disk::RemoteDisk;
pub use remote_locker::RemoteClient;
+1 -1
View File
@@ -2263,7 +2263,7 @@ impl DiskAPI for RemoteDisk {
#[cfg(test)]
mod tests {
use super::*;
use crate::rpc::{InternodeDataTransportCapabilities, TcpHttpInternodeDataTransport};
use crate::rpc::internode_data_transport::{InternodeDataTransportCapabilities, TcpHttpInternodeDataTransport};
use rustfs_common::GLOBAL_CONN_MAP;
use serde_json::Value;
use std::io::{self as std_io, Write};
+4 -6
View File
@@ -104,8 +104,6 @@ type ListObjectVersionsInfo = StorageListObjectVersionsInfo<ObjectInfo>;
type ObjectInfoOrErr = StorageObjectInfoOrErr<ObjectInfo, Error>;
type WalkOptions = StorageWalkOptions<fn(&FileInfo) -> bool>;
pub use crate::layout::pool_space::{PoolAvailableSpace, ServerPoolsAvailableSpace, has_space_for};
/// Check if a directory contains any xl.meta files (indicating actual S3 objects)
/// This is used to determine if a bucket is empty for deletion purposes.
async fn has_xlmeta_files(path: &std::path::Path) -> bool {
@@ -176,8 +174,8 @@ mod rebalance;
use peer::init_local_peer;
pub use peer::{
all_local_disk, all_local_disk_path, find_local_disk, find_local_disk_by_ref, get_disk_infos, get_disk_via_endpoint,
init_local_disks, init_lock_clients, prewarm_local_disk_id_map,
all_local_disk, all_local_disk_path, find_local_disk_by_ref, get_disk_infos, init_local_disks, init_lock_clients,
prewarm_local_disk_id_map,
};
pub struct ECStore {
@@ -788,14 +786,14 @@ mod tests {
async fn test_has_space_for() {
let disk_infos = vec![None, None]; // No actual disk info
let result = has_space_for(&disk_infos, 1024).await;
let result = crate::layout::pool_space::has_space_for(&disk_infos, 1024).await;
// Should fail due to no valid disk info
assert!(result.is_err());
}
#[tokio::test]
async fn test_find_local_disk() {
let result = find_local_disk(&"/nonexistent/path".to_string()).await;
let result = peer::find_local_disk(&"/nonexistent/path".to_string()).await;
assert!(result.is_none(), "Should return None for nonexistent path");
}
+1 -1
View File
@@ -14,7 +14,7 @@
use super::*;
use crate::config::get_global_storage_class;
use crate::layout::pool_space::build_server_pools_available_space;
use crate::layout::pool_space::{ServerPoolsAvailableSpace, build_server_pools_available_space};
use rustfs_storage_api::{NamespaceLocking as _, ObjectOperations as _, StorageAdminApi};
pub(in crate::store) mod support;
use support::{