refactor: use relative storage compat consumers (#3727)

This commit is contained in:
安正超
2026-06-22 13:52:45 +08:00
committed by GitHub
parent da08e411f1
commit c8de6cac75
6 changed files with 70 additions and 28 deletions
+5 -5
View File
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use super::storage_compat::DEFAULT_READ_BUFFER_SIZE;
use super::storage_compat::StorageDiskRpcExt as _;
use super::storage_compat::WalkDirOptions;
use super::storage_compat::find_local_disk_by_ref;
use super::storage_compat::verify_rpc_signature;
use crate::server::RPC_PREFIX;
use crate::storage::request_context::spawn_traced;
use crate::storage::rpc::storage_compat::DEFAULT_READ_BUFFER_SIZE;
use crate::storage::rpc::storage_compat::StorageDiskRpcExt as _;
use crate::storage::rpc::storage_compat::WalkDirOptions;
use crate::storage::rpc::storage_compat::find_local_disk_by_ref;
use crate::storage::rpc::storage_compat::verify_rpc_signature;
use bytes::{Bytes, BytesMut};
use futures_util::TryStreamExt;
use http::{HeaderMap, Method, Request, Response, StatusCode, Uri};
+10 -10
View File
@@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::admin::service::{
config::{reload_dynamic_config_runtime_state, reload_runtime_config_snapshot},
site_replication::reload_site_replication_runtime_state,
};
use crate::storage::rpc::storage_compat::{
use super::storage_compat::{
CollectMetricsOpts, DeleteOptions, DiskError, DiskInfoOptions, DiskStore, FileInfoVersions, LocalPeerS3Client, MetricType,
PEER_RESTSIGNAL, PEER_RESTSUB_SYS, ReadMultipleReq, ReadMultipleResp, ReadOptions, SERVICE_SIGNAL_REFRESH_CONFIG,
SERVICE_SIGNAL_RELOAD_DYNAMIC, StorageDiskRpcExt as _, StoragePeerS3ClientExt as _, UpdateMetadataOpts, all_local_disk_path,
collect_local_metrics, find_local_disk_by_ref, get_global_lock_client, get_local_server_property, load_bucket_metadata,
reload_transition_tier_config, resolve_object_store_handle, set_bucket_metadata,
};
use crate::admin::service::{
config::{reload_dynamic_config_runtime_state, reload_runtime_config_snapshot},
site_replication::reload_site_replication_runtime_state,
};
use bytes::Bytes;
use futures::Stream;
use futures_util::future::join_all;
@@ -122,11 +122,11 @@ fn unimplemented_rpc(method: &str) -> Status {
Status::unimplemented(format!("{method} is not implemented"))
}
fn background_rebalance_start_error_message(result: crate::storage::rpc::storage_compat::Result<()>) -> Option<String> {
fn background_rebalance_start_error_message(result: super::storage_compat::Result<()>) -> Option<String> {
result.err().map(|err| format!("start_rebalance failed: {err}"))
}
fn stop_rebalance_response(result: crate::storage::rpc::storage_compat::Result<()>) -> StopRebalanceResponse {
fn stop_rebalance_response(result: super::storage_compat::Result<()>) -> StopRebalanceResponse {
match result {
Ok(_) => StopRebalanceResponse {
success: true,
@@ -2389,7 +2389,7 @@ mod tests {
#[test]
fn test_background_rebalance_start_error_message_formats_error() {
let message = background_rebalance_start_error_message(Err(crate::storage::rpc::storage_compat::Error::other("boom")))
let message = background_rebalance_start_error_message(Err(super::super::storage_compat::Error::other("boom")))
.expect("background rebalance start failure should be formatted");
assert!(message.contains("start_rebalance failed"));
@@ -2398,7 +2398,7 @@ mod tests {
#[test]
fn test_stop_rebalance_response_reports_local_stop_error() {
let response = stop_rebalance_response(Err(crate::storage::rpc::storage_compat::Error::other("boom")));
let response = stop_rebalance_response(Err(super::super::storage_compat::Error::other("boom")));
assert!(!response.success);
assert!(response.error_info.as_deref().is_some_and(|message| message.contains("boom")));
@@ -2736,7 +2736,7 @@ mod tests {
vars.insert(PEER_RESTSIGNAL.to_string(), SERVICE_SIGNAL_RELOAD_DYNAMIC.to_string());
vars.insert(
PEER_RESTSUB_SYS.to_string(),
crate::storage::rpc::storage_compat::STORAGE_CLASS_SUB_SYS.to_string(),
super::super::storage_compat::STORAGE_CLASS_SUB_SYS.to_string(),
);
let request = Request::new(SignalServiceRequest {
+1 -1
View File
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use super::storage_compat::to_s3s_etag;
use crate::storage::s3_api::common::rustfs_owner;
use crate::storage::s3_api::storage_compat::to_s3s_etag;
use percent_encoding::percent_decode_str;
use rustfs_storage_api::{
BucketInfo, ListObjectVersionsInfo as StorageListObjectVersionsInfo, ListObjectsV2Info as StorageListObjectsV2Info,
+2 -2
View File
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use super::storage_compat::to_s3s_etag;
use crate::storage::s3_api::common::{rustfs_initiator, rustfs_owner};
use crate::storage::s3_api::storage_compat::to_s3s_etag;
use rustfs_storage_api::{ListMultipartsInfo, ListPartsInfo};
use s3s::dto::{CommonPrefix, ListMultipartUploadsOutput, ListPartsOutput, MultipartUpload, Part, Timestamp};
use s3s::{S3Error, S3ErrorCode};
@@ -186,12 +186,12 @@ pub(crate) fn build_list_multipart_uploads_output(
#[cfg(test)]
mod tests {
use super::super::storage_compat::to_s3s_etag;
use super::{
MAX_MULTIPART_UPLOADS_LIST, build_list_multipart_uploads_output, build_list_parts_output,
parse_list_multipart_uploads_params, parse_list_parts_params, parse_upload_part_number,
};
use crate::storage::s3_api::common::{rustfs_initiator, rustfs_owner};
use crate::storage::s3_api::storage_compat::to_s3s_etag;
use rustfs_storage_api::{ListMultipartsInfo, ListPartsInfo, MultipartInfo, PartInfo};
use s3s::S3ErrorCode;
use s3s::dto::Timestamp;