feat(storage-api): bind ecstore admin contract (#3331)

This commit is contained in:
安正超
2026-06-11 05:49:14 +08:00
committed by GitHub
parent 474fab5097
commit 4b1714438e
3 changed files with 98 additions and 28 deletions
+33
View File
@@ -730,6 +730,39 @@ impl StorageAPI for ECStore {
}
}
#[async_trait::async_trait]
impl rustfs_storage_api::StorageAdminApi for ECStore {
type BackendInfo = rustfs_madmin::BackendInfo;
type StorageInfo = rustfs_madmin::StorageInfo;
type Disk = DiskStore;
type Error = Error;
#[instrument(skip(self))]
async fn backend_info(&self) -> Self::BackendInfo {
self.handle_backend_info().await
}
#[instrument(skip(self))]
async fn storage_info(&self) -> Self::StorageInfo {
self.handle_storage_info().await
}
#[instrument(skip(self))]
async fn local_storage_info(&self) -> Self::StorageInfo {
self.handle_local_storage_info().await
}
#[instrument(skip(self))]
async fn disk_set_inventory(&self, selector: rustfs_storage_api::DiskSetSelector) -> Result<Vec<Option<Self::Disk>>> {
self.handle_get_disks(selector.pool_idx, selector.set_idx).await
}
#[instrument(skip(self))]
fn set_drive_counts(&self) -> Vec<usize> {
self.handle_set_drive_counts()
}
}
#[derive(Debug, Default, Clone)]
pub struct PoolAvailableSpace {
pub index: usize,
@@ -15,8 +15,9 @@
use rustfs_ecstore::store_api::{
BucketInfo as EcstoreBucketInfo, BucketOptions as EcstoreBucketOptions, MakeBucketOptions as EcstoreMakeBucketOptions,
};
use rustfs_ecstore::{disk::DiskStore, error::Error, store::ECStore};
use rustfs_storage_api::{
BucketInfo as ApiBucketInfo, BucketOptions as ApiBucketOptions, MakeBucketOptions as ApiMakeBucketOptions,
BucketInfo as ApiBucketInfo, BucketOptions as ApiBucketOptions, MakeBucketOptions as ApiMakeBucketOptions, StorageAdminApi,
};
#[test]
@@ -36,3 +37,20 @@ fn old_store_api_bucket_dto_path_reexports_storage_api_types() {
assert!(!ecstore_make.lock_enabled);
assert!(!api_options.no_metadata);
}
fn storage_admin_api_type_name<T>() -> &'static str
where
T: StorageAdminApi<
BackendInfo = rustfs_madmin::BackendInfo,
StorageInfo = rustfs_madmin::StorageInfo,
Disk = DiskStore,
Error = Error,
>,
{
std::any::type_name::<T>()
}
#[test]
fn ecstore_implements_storage_admin_api_contract() {
assert!(storage_admin_api_type_name::<ECStore>().ends_with("::ECStore"));
}