mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 11:06:17 +00:00
refactor(app): route metadata/endpoints access through AppContext (#1949)
This commit is contained in:
@@ -20,9 +20,10 @@ use crate::error::ApiError;
|
||||
use rustfs_common::data_usage::DataUsageInfo;
|
||||
use rustfs_ecstore::admin_server_info::get_server_info;
|
||||
use rustfs_ecstore::data_usage::load_data_usage_from_backend;
|
||||
use rustfs_ecstore::endpoints::EndpointServerPools;
|
||||
use rustfs_ecstore::new_object_layer_fn;
|
||||
use rustfs_ecstore::pools::{PoolStatus, get_total_usable_capacity, get_total_usable_capacity_free};
|
||||
use rustfs_ecstore::store_api::StorageAPI;
|
||||
use rustfs_ecstore::{GLOBAL_Endpoints, new_object_layer_fn};
|
||||
use rustfs_madmin::{InfoMessage, StorageInfo};
|
||||
use s3s::S3ErrorCode;
|
||||
use std::sync::Arc;
|
||||
@@ -96,6 +97,13 @@ impl DefaultAdminUsecase {
|
||||
self.context.clone()
|
||||
}
|
||||
|
||||
fn endpoints(&self) -> Option<EndpointServerPools> {
|
||||
self.context
|
||||
.as_ref()
|
||||
.and_then(|context| context.endpoints().handle())
|
||||
.or_else(|| rustfs_ecstore::GLOBAL_Endpoints.get().cloned())
|
||||
}
|
||||
|
||||
fn app_error(code: S3ErrorCode, message: impl Into<String>) -> ApiError {
|
||||
ApiError {
|
||||
code,
|
||||
@@ -221,7 +229,7 @@ impl DefaultAdminUsecase {
|
||||
return Err(Self::app_error(S3ErrorCode::InternalError, "Not init"));
|
||||
};
|
||||
|
||||
let Some(endpoints) = GLOBAL_Endpoints.get() else {
|
||||
let Some(endpoints) = self.endpoints() else {
|
||||
return Err(Self::app_error_default(S3ErrorCode::NotImplemented));
|
||||
};
|
||||
|
||||
@@ -243,7 +251,7 @@ impl DefaultAdminUsecase {
|
||||
let _ = context.object_store();
|
||||
}
|
||||
|
||||
let Some(endpoints) = GLOBAL_Endpoints.get() else {
|
||||
let Some(endpoints) = self.endpoints() else {
|
||||
return Err(Self::app_error_default(S3ErrorCode::NotImplemented));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user