refactor: prune consumer storage compat paths (#3704)

This commit is contained in:
安正超
2026-06-22 02:31:30 +08:00
committed by GitHub
parent e528ee9452
commit d39815470e
14 changed files with 280 additions and 196 deletions
+27 -22
View File
@@ -14,17 +14,22 @@
use std::sync::Arc;
pub(crate) const IAM_CONFIG_ROOT_PREFIX: &str = rustfs_ecstore::api::config::RUSTFS_CONFIG_PREFIX;
use rustfs_ecstore::api::{
config as ecstore_config, error as ecstore_error, global as ecstore_global, notification as ecstore_notification,
storage as ecstore_storage,
};
pub(crate) type IamEcstoreError = rustfs_ecstore::api::error::Error;
pub(crate) type IamStorageError = rustfs_ecstore::api::error::StorageError;
pub(crate) type IamStorageResult<T> = rustfs_ecstore::api::error::Result<T>;
pub(crate) type IamStore = rustfs_ecstore::api::storage::ECStore;
pub(crate) const IAM_CONFIG_ROOT_PREFIX: &str = ecstore_config::RUSTFS_CONFIG_PREFIX;
pub(crate) type IamEcstoreError = ecstore_error::Error;
pub(crate) type IamStorageError = ecstore_error::StorageError;
pub(crate) type IamStorageResult<T> = ecstore_error::Result<T>;
pub(crate) type IamStore = ecstore_storage::ECStore;
pub(crate) type IamConfigObjectInfo = <IamStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
pub(crate) type IamConfigObjectOptions = <IamStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
pub(crate) async fn read_iam_config_no_lock(api: Arc<IamStore>, file: &str) -> IamStorageResult<Vec<u8>> {
rustfs_ecstore::api::config::com::read_config_no_lock(api, file).await
ecstore_config::com::read_config_no_lock(api, file).await
}
pub(crate) async fn read_iam_config_with_metadata(
@@ -32,11 +37,11 @@ pub(crate) async fn read_iam_config_with_metadata(
file: &str,
opts: &IamConfigObjectOptions,
) -> IamStorageResult<(Vec<u8>, IamConfigObjectInfo)> {
rustfs_ecstore::api::config::com::read_config_with_metadata(api, file, opts).await
ecstore_config::com::read_config_with_metadata(api, file, opts).await
}
pub(crate) async fn save_iam_config(api: Arc<IamStore>, file: &str, data: Vec<u8>) -> IamStorageResult<()> {
rustfs_ecstore::api::config::com::save_config(api, file, data).await
ecstore_config::com::save_config(api, file, data).await
}
pub(crate) async fn save_iam_config_with_opts(
@@ -45,33 +50,33 @@ pub(crate) async fn save_iam_config_with_opts(
data: Vec<u8>,
opts: &IamConfigObjectOptions,
) -> IamStorageResult<()> {
rustfs_ecstore::api::config::com::save_config_with_opts(api, file, data, opts).await
ecstore_config::com::save_config_with_opts(api, file, data, opts).await
}
pub(crate) async fn delete_iam_config(api: Arc<IamStore>, file: &str) -> IamStorageResult<()> {
rustfs_ecstore::api::config::com::delete_config(api, file).await
ecstore_config::com::delete_config(api, file).await
}
pub(crate) fn classify_iam_system_path_failure_reason(err: &IamEcstoreError) -> &'static str {
rustfs_ecstore::api::error::classify_system_path_failure_reason(err)
ecstore_error::classify_system_path_failure_reason(err)
}
pub(crate) async fn is_iam_first_cluster_node_local() -> bool {
rustfs_ecstore::api::global::is_first_cluster_node_local().await
ecstore_global::is_first_cluster_node_local().await
}
pub(crate) struct IamNotificationPeerErr {
pub(crate) err: Option<IamEcstoreError>,
}
impl From<rustfs_ecstore::api::notification::NotificationPeerErr> for IamNotificationPeerErr {
fn from(value: rustfs_ecstore::api::notification::NotificationPeerErr) -> Self {
impl From<ecstore_notification::NotificationPeerErr> for IamNotificationPeerErr {
fn from(value: ecstore_notification::NotificationPeerErr) -> Self {
Self { err: value.err }
}
}
pub(crate) async fn notify_iam_delete_policy(policy_name: &str) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.delete_policy(policy_name)
.await
@@ -83,7 +88,7 @@ pub(crate) async fn notify_iam_delete_policy(policy_name: &str) -> Vec<IamNotifi
}
pub(crate) async fn notify_iam_load_policy(policy_name: &str) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_policy(policy_name)
.await
@@ -95,7 +100,7 @@ pub(crate) async fn notify_iam_load_policy(policy_name: &str) -> Vec<IamNotifica
}
pub(crate) async fn notify_iam_delete_user(access_key: &str) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.delete_user(access_key)
.await
@@ -107,7 +112,7 @@ pub(crate) async fn notify_iam_delete_user(access_key: &str) -> Vec<IamNotificat
}
pub(crate) async fn notify_iam_load_user(access_key: &str, temp: bool) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_user(access_key, temp)
.await
@@ -119,7 +124,7 @@ pub(crate) async fn notify_iam_load_user(access_key: &str, temp: bool) -> Vec<Ia
}
pub(crate) async fn notify_iam_load_service_account(access_key: &str) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_service_account(access_key)
.await
@@ -131,7 +136,7 @@ pub(crate) async fn notify_iam_load_service_account(access_key: &str) -> Vec<Iam
}
pub(crate) async fn notify_iam_delete_service_account(access_key: &str) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.delete_service_account(access_key)
.await
@@ -143,7 +148,7 @@ pub(crate) async fn notify_iam_delete_service_account(access_key: &str) -> Vec<I
}
pub(crate) async fn notify_iam_load_group(group: &str) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys.load_group(group).await.into_iter().map(Into::into).collect(),
None => Vec::new(),
}
@@ -154,7 +159,7 @@ pub(crate) async fn notify_iam_load_policy_mapping(
user_type: u64,
is_group: bool,
) -> Vec<IamNotificationPeerErr> {
match rustfs_ecstore::api::notification::get_global_notification_sys() {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_policy_mapping(user_or_group, user_type, is_group)
.await