refactor: clean config storage boundaries (#3489)

This commit is contained in:
安正超
2026-06-16 06:35:32 +08:00
committed by GitHub
parent fbab160c2b
commit c26593fa7a
5 changed files with 33 additions and 311 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ use crate::client::{
};
use crate::{
disk::DiskAPI,
store_api::{GetObjectReader, ObjectInfo, StorageAPI},
store_api::{GetObjectReader, ObjectInfo},
};
use rustfs_utils::hash::EMPTY_STRING_SHA256_HASH;
+1 -279
View File
@@ -1217,12 +1217,7 @@ mod tests {
use crate::error::{Error, Result};
use crate::global::{is_dist_erasure, is_erasure, is_erasure_sd, update_erasure_type};
use crate::set_disk::SetDisks;
use crate::store_api::{
BucketInfo, BucketOperations, BucketOptions, CompletePart, DeleteBucketOptions, DeletedObject, GetObjectReader,
HTTPRangeSpec, HealOperations, ListMultipartsInfo, ListObjectVersionsInfo, ListObjectsV2Info, ListOperations,
MakeBucketOptions, MultipartInfo, MultipartOperations, MultipartUploadResult, NamespaceLocking, ObjectIO, ObjectInfo,
ObjectOperations, ObjectOptions, ObjectToDelete, PartInfo, PutObjReader, StorageAPI, WalkOptions,
};
use crate::store_api::{GetObjectReader, HTTPRangeSpec, NamespaceLocking, ObjectIO, ObjectInfo, ObjectOptions, PutObjReader};
use http::HeaderMap;
use rustfs_config::audit::{AUDIT_AMQP_SUB_SYS, AUDIT_KAFKA_SUB_SYS, AUDIT_MQTT_SUB_SYS, AUDIT_WEBHOOK_SUB_SYS};
use rustfs_config::notify::{
@@ -1233,7 +1228,6 @@ mod tests {
use rustfs_config::{
DEFAULT_DELIMITER, ENABLE_KEY, EnableState, MYSQL_DSN_STRING, MYSQL_MAX_OPEN_CONNECTIONS, MYSQL_QUEUE_DIR, MYSQL_TABLE,
};
use rustfs_filemeta::FileInfo;
use rustfs_lock::client::LockClient;
use rustfs_lock::client::local::LocalClient;
use rustfs_lock::{LockError, LockInfo, LockResponse, LockStats};
@@ -1249,7 +1243,6 @@ mod tests {
use time::OffsetDateTime;
use tokio::io::{AsyncRead, ReadBuf};
use tokio::sync::RwLock;
use tokio_util::sync::CancellationToken;
#[derive(Debug, Default)]
struct FailingClient;
@@ -1457,277 +1450,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl BucketOperations for LockingConfigStorage {
async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> {
panic!("unused in test")
}
async fn get_bucket_info(&self, _bucket: &str, _opts: &BucketOptions) -> Result<BucketInfo> {
panic!("unused in test")
}
async fn list_bucket(&self, _opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
panic!("unused in test")
}
async fn delete_bucket(&self, _bucket: &str, _opts: &DeleteBucketOptions) -> Result<()> {
panic!("unused in test")
}
}
#[async_trait::async_trait]
impl ObjectOperations for LockingConfigStorage {
async fn get_object_info(&self, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<ObjectInfo> {
panic!("unused in test")
}
async fn verify_object_integrity(&self, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<()> {
panic!("unused in test")
}
async fn copy_object(
&self,
_src_bucket: &str,
_src_object: &str,
_dst_bucket: &str,
_dst_object: &str,
_src_info: &mut ObjectInfo,
_src_opts: &ObjectOptions,
_dst_opts: &ObjectOptions,
) -> Result<ObjectInfo> {
panic!("unused in test")
}
async fn delete_object_version(
&self,
_bucket: &str,
_object: &str,
_fi: &FileInfo,
_force_del_marker: bool,
) -> Result<()> {
panic!("unused in test")
}
async fn delete_object(&self, _bucket: &str, _object: &str, _opts: ObjectOptions) -> Result<ObjectInfo> {
panic!("unused in test")
}
async fn delete_objects(
&self,
_bucket: &str,
_objects: Vec<ObjectToDelete>,
_opts: ObjectOptions,
) -> (Vec<DeletedObject>, Vec<Option<Error>>) {
panic!("unused in test")
}
async fn put_object_metadata(&self, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<ObjectInfo> {
panic!("unused in test")
}
async fn get_object_tags(&self, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<String> {
panic!("unused in test")
}
async fn put_object_tags(&self, _bucket: &str, _object: &str, _tags: &str, _opts: &ObjectOptions) -> Result<ObjectInfo> {
panic!("unused in test")
}
async fn delete_object_tags(&self, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<ObjectInfo> {
panic!("unused in test")
}
async fn add_partial(&self, _bucket: &str, _object: &str, _version_id: &str) -> Result<()> {
panic!("unused in test")
}
async fn transition_object(&self, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<()> {
panic!("unused in test")
}
async fn restore_transitioned_object(self: Arc<Self>, _bucket: &str, _object: &str, _opts: &ObjectOptions) -> Result<()> {
panic!("unused in test")
}
}
#[async_trait::async_trait]
impl ListOperations for LockingConfigStorage {
async fn list_objects_v2(
self: Arc<Self>,
_bucket: &str,
_prefix: &str,
_continuation_token: Option<String>,
_delimiter: Option<String>,
_max_keys: i32,
_fetch_owner: bool,
_start_after: Option<String>,
_incl_deleted: bool,
) -> Result<ListObjectsV2Info> {
panic!("unused in test")
}
async fn list_object_versions(
self: Arc<Self>,
_bucket: &str,
_prefix: &str,
_marker: Option<String>,
_version_marker: Option<String>,
_delimiter: Option<String>,
_max_keys: i32,
) -> Result<ListObjectVersionsInfo> {
panic!("unused in test")
}
async fn walk(
self: Arc<Self>,
_rx: CancellationToken,
_bucket: &str,
_prefix: &str,
_result: tokio::sync::mpsc::Sender<crate::store_api::ObjectInfoOrErr>,
_opts: WalkOptions,
) -> Result<()> {
panic!("unused in test")
}
}
#[async_trait::async_trait]
impl MultipartOperations for LockingConfigStorage {
async fn list_multipart_uploads(
&self,
_bucket: &str,
_prefix: &str,
_key_marker: Option<String>,
_upload_id_marker: Option<String>,
_delimiter: Option<String>,
_max_uploads: usize,
) -> Result<ListMultipartsInfo> {
panic!("unused in test")
}
async fn new_multipart_upload(
&self,
_bucket: &str,
_object: &str,
_opts: &ObjectOptions,
) -> Result<MultipartUploadResult> {
panic!("unused in test")
}
async fn copy_object_part(
&self,
_src_bucket: &str,
_src_object: &str,
_dst_bucket: &str,
_dst_object: &str,
_upload_id: &str,
_part_id: usize,
_start_offset: i64,
_length: i64,
_src_info: &ObjectInfo,
_src_opts: &ObjectOptions,
_dst_opts: &ObjectOptions,
) -> Result<()> {
panic!("unused in test")
}
async fn put_object_part(
&self,
_bucket: &str,
_object: &str,
_upload_id: &str,
_part_id: usize,
_data: &mut PutObjReader,
_opts: &ObjectOptions,
) -> Result<PartInfo> {
panic!("unused in test")
}
async fn get_multipart_info(
&self,
_bucket: &str,
_object: &str,
_upload_id: &str,
_opts: &ObjectOptions,
) -> Result<MultipartInfo> {
panic!("unused in test")
}
async fn list_object_parts(
&self,
_bucket: &str,
_object: &str,
_upload_id: &str,
_part_number_marker: Option<usize>,
_max_parts: usize,
_opts: &ObjectOptions,
) -> Result<crate::store_api::ListPartsInfo> {
panic!("unused in test")
}
async fn abort_multipart_upload(
&self,
_bucket: &str,
_object: &str,
_upload_id: &str,
_opts: &ObjectOptions,
) -> Result<()> {
panic!("unused in test")
}
async fn complete_multipart_upload(
self: Arc<Self>,
_bucket: &str,
_object: &str,
_upload_id: &str,
_uploaded_parts: Vec<CompletePart>,
_opts: &ObjectOptions,
) -> Result<ObjectInfo> {
panic!("unused in test")
}
}
#[async_trait::async_trait]
impl HealOperations for LockingConfigStorage {
async fn heal_format(&self, _dry_run: bool) -> Result<(rustfs_madmin::heal_commands::HealResultItem, Option<Error>)> {
panic!("unused in test")
}
async fn heal_bucket(
&self,
_bucket: &str,
_opts: &rustfs_common::heal_channel::HealOpts,
) -> Result<rustfs_madmin::heal_commands::HealResultItem> {
panic!("unused in test")
}
async fn heal_object(
&self,
_bucket: &str,
_object: &str,
_version_id: &str,
_opts: &rustfs_common::heal_channel::HealOpts,
) -> Result<(rustfs_madmin::heal_commands::HealResultItem, Option<Error>)> {
panic!("unused in test")
}
async fn get_pool_and_set(&self, _id: &str) -> Result<(Option<usize>, Option<usize>, Option<usize>)> {
panic!("unused in test")
}
async fn check_abandoned_parts(
&self,
_bucket: &str,
_object: &str,
_opts: &rustfs_common::heal_channel::HealOpts,
) -> Result<()> {
panic!("unused in test")
}
}
#[async_trait::async_trait]
impl StorageAPI for LockingConfigStorage {}
#[async_trait::async_trait]
impl NamespaceLocking for LockingConfigStorage {
async fn new_ns_lock(&self, bucket: &str, object: &str) -> Result<rustfs_lock::NamespaceLockWrapper> {
+2 -2
View File
@@ -1552,8 +1552,8 @@ fn get_quorum_disk_infos(disks: &[DiskStore], infos: &[DiskInfo], read_quorum: u
for (i, info) in infos.iter().enumerate() {
let mutations = info.metrics.total_deletes + info.metrics.total_writes;
if mutations >= common_mutations {
new_disks.push(disks[i].clone()); // Assuming StorageAPI derives Clone
new_infos.push(infos[i].clone()); // Assuming DiskInfo derives Clone
new_disks.push(disks[i].clone());
new_infos.push(infos[i].clone());
}
}