mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-17 18:27:49 +00:00
refactor: route remaining external storage boundaries (#3889)
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
|
||||
//! Swift account operations and validation
|
||||
|
||||
use super::storage_api::{BucketOperations, MakeBucketOptions};
|
||||
use super::{SwiftError, SwiftResult};
|
||||
use super::{get_swift_bucket_metadata, resolve_swift_object_store_handle, set_swift_bucket_metadata};
|
||||
use rustfs_credentials::Credentials;
|
||||
use rustfs_storage_api::{BucketOperations, MakeBucketOptions};
|
||||
use s3s::dto::{Tag, Tagging};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
//! This module implements Swift container CRUD operations and container-bucket translation.
|
||||
|
||||
use super::account::validate_account_access;
|
||||
use super::storage_api::{
|
||||
BucketInfo, BucketOperations, BucketOptions, DeleteBucketOptions, ListOperations as _, MakeBucketOptions,
|
||||
};
|
||||
use super::types::Container;
|
||||
use super::{SwiftError, SwiftResult};
|
||||
use super::{get_swift_bucket_metadata, resolve_swift_object_store_handle, set_swift_bucket_metadata};
|
||||
use rustfs_credentials::Credentials;
|
||||
use rustfs_storage_api::{
|
||||
BucketInfo, BucketOperations, BucketOptions, DeleteBucketOptions, ListOperations as _, MakeBucketOptions,
|
||||
};
|
||||
use s3s::dto::{Tag, Tagging};
|
||||
use sha2::{Digest, Sha256};
|
||||
use tracing::{debug, error};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//! Segments are discovered at download time using lexicographic ordering
|
||||
//! based on a container metadata manifest pointer.
|
||||
|
||||
use super::storage_api::HTTPRangeSpec;
|
||||
use super::{SwiftError, container, object};
|
||||
use axum::http::{HeaderMap, Response, StatusCode};
|
||||
use rustfs_credentials::Credentials;
|
||||
@@ -300,7 +301,7 @@ async fn create_dlo_stream(
|
||||
|
||||
async move {
|
||||
let range_spec = if byte_start > 0 || byte_end < segment.size as u64 - 1 {
|
||||
Some(rustfs_storage_api::HTTPRangeSpec {
|
||||
Some(HTTPRangeSpec {
|
||||
is_suffix_length: false,
|
||||
start: byte_start as i64,
|
||||
end: byte_end as i64,
|
||||
|
||||
@@ -33,16 +33,6 @@
|
||||
//! and stores credentials in task-local storage, which Swift handlers access
|
||||
//! to enforce tenant isolation.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) use rustfs_ecstore::api::bucket::metadata::BucketMetadata as SwiftBucketMetadata;
|
||||
use rustfs_ecstore::api::bucket::metadata_sys::{
|
||||
get as get_swift_bucket_metadata_from_backend, set_bucket_metadata as set_swift_bucket_metadata_in_backend,
|
||||
};
|
||||
pub(crate) use rustfs_ecstore::api::error::Result as SwiftStorageResult;
|
||||
pub(crate) use rustfs_ecstore::api::global::resolve_object_store_handle as resolve_swift_object_store_handle;
|
||||
use rustfs_ecstore::api::storage::ECStore as SwiftStore;
|
||||
|
||||
pub mod account;
|
||||
pub mod acl;
|
||||
pub mod bulk;
|
||||
@@ -61,6 +51,7 @@ pub mod ratelimit;
|
||||
pub mod router;
|
||||
pub mod slo;
|
||||
pub mod staticweb;
|
||||
mod storage_api;
|
||||
pub mod symlink;
|
||||
pub mod sync;
|
||||
pub mod tempurl;
|
||||
@@ -70,18 +61,7 @@ pub mod versioning;
|
||||
pub use errors::{SwiftError, SwiftResult};
|
||||
pub use router::{SwiftRoute, SwiftRouter};
|
||||
// Note: Container, Object, and SwiftMetadata types used by Swift implementation
|
||||
pub use storage_api::{SwiftGetObjectReader, SwiftObjectInfo, SwiftObjectOptions, SwiftPutObjReader};
|
||||
pub(crate) use storage_api::{get_swift_bucket_metadata, resolve_swift_object_store_handle, set_swift_bucket_metadata};
|
||||
#[allow(unused_imports)]
|
||||
pub use types::{Container, Object, SwiftMetadata};
|
||||
|
||||
pub type SwiftGetObjectReader = <SwiftStore as rustfs_storage_api::ObjectIO>::GetObjectReader;
|
||||
pub type SwiftObjectInfo = <SwiftStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
|
||||
pub type SwiftObjectOptions = <SwiftStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
|
||||
pub type SwiftPutObjReader = <SwiftStore as rustfs_storage_api::ObjectIO>::PutObjectReader;
|
||||
|
||||
pub(crate) async fn get_swift_bucket_metadata(bucket: &str) -> SwiftStorageResult<Arc<SwiftBucketMetadata>> {
|
||||
get_swift_bucket_metadata_from_backend(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn set_swift_bucket_metadata(bucket: String, metadata: SwiftBucketMetadata) -> SwiftStorageResult<()> {
|
||||
set_swift_bucket_metadata_in_backend(bucket, metadata).await
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@
|
||||
|
||||
use super::account::validate_account_access;
|
||||
use super::container::ContainerMapper;
|
||||
use super::storage_api::{BucketOperations, BucketOptions, HTTPRangeSpec, ObjectIO as _, ObjectOperations as _};
|
||||
use super::{SwiftError, SwiftResult, resolve_swift_object_store_handle};
|
||||
use axum::http::HeaderMap;
|
||||
use rustfs_credentials::Credentials;
|
||||
use rustfs_rio::HashReader;
|
||||
use rustfs_storage_api::{BucketOperations, BucketOptions, ObjectIO as _, ObjectOperations as _};
|
||||
use std::collections::HashMap;
|
||||
use tracing::debug;
|
||||
use tracing::error;
|
||||
@@ -533,7 +533,7 @@ pub async fn get_object(
|
||||
container: &str,
|
||||
object: &str,
|
||||
credentials: &Credentials,
|
||||
range: Option<rustfs_storage_api::HTTPRangeSpec>,
|
||||
range: Option<HTTPRangeSpec>,
|
||||
) -> SwiftResult<SwiftGetObjectReader> {
|
||||
// 1. Validate account access and get project_id
|
||||
let project_id = validate_account_access(account, credentials)?;
|
||||
@@ -1028,9 +1028,7 @@ pub fn parse_copy_from_header(copy_from: &str) -> SwiftResult<(String, String)>
|
||||
/// assert_eq!(range.end, 1023);
|
||||
/// ```
|
||||
#[allow(dead_code)] // Handler integration: Range header
|
||||
pub fn parse_range_header(range_str: &str) -> SwiftResult<rustfs_storage_api::HTTPRangeSpec> {
|
||||
use rustfs_storage_api::HTTPRangeSpec;
|
||||
|
||||
pub fn parse_range_header(range_str: &str) -> SwiftResult<HTTPRangeSpec> {
|
||||
if !range_str.starts_with("bytes=") {
|
||||
return Err(SwiftError::BadRequest("Range header must start with 'bytes='".to_string()));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//! Large files (>5GB) are split into segments, and a manifest defines
|
||||
//! how segments are assembled on download.
|
||||
|
||||
use super::storage_api::HTTPRangeSpec;
|
||||
use super::{SwiftError, object};
|
||||
use axum::http::{HeaderMap, Response, StatusCode};
|
||||
use rustfs_credentials::Credentials;
|
||||
@@ -420,7 +421,7 @@ async fn create_slo_stream(
|
||||
|
||||
// Fetch segment with range
|
||||
let range_spec = if byte_start > 0 || byte_end < segment.size_bytes - 1 {
|
||||
Some(rustfs_storage_api::HTTPRangeSpec {
|
||||
Some(HTTPRangeSpec {
|
||||
is_suffix_length: false,
|
||||
start: byte_start as i64,
|
||||
end: byte_end as i64,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) use rustfs_ecstore::api::bucket::metadata::BucketMetadata as SwiftBucketMetadata;
|
||||
use rustfs_ecstore::api::bucket::metadata_sys::{
|
||||
get as get_swift_bucket_metadata_from_backend, set_bucket_metadata as set_swift_bucket_metadata_in_backend,
|
||||
};
|
||||
pub(crate) use rustfs_ecstore::api::error::Result as SwiftStorageResult;
|
||||
pub(crate) use rustfs_ecstore::api::global::resolve_object_store_handle as resolve_swift_object_store_handle;
|
||||
use rustfs_ecstore::api::storage::ECStore as SwiftStore;
|
||||
pub(crate) use rustfs_storage_api::{
|
||||
BucketInfo, BucketOperations, BucketOptions, DeleteBucketOptions, HTTPRangeSpec, ListOperations, MakeBucketOptions, ObjectIO,
|
||||
ObjectOperations,
|
||||
};
|
||||
|
||||
pub type SwiftGetObjectReader = <SwiftStore as rustfs_storage_api::ObjectIO>::GetObjectReader;
|
||||
pub type SwiftObjectInfo = <SwiftStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
|
||||
pub type SwiftObjectOptions = <SwiftStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
|
||||
pub type SwiftPutObjReader = <SwiftStore as rustfs_storage_api::ObjectIO>::PutObjectReader;
|
||||
|
||||
pub(crate) async fn get_swift_bucket_metadata(bucket: &str) -> SwiftStorageResult<Arc<SwiftBucketMetadata>> {
|
||||
get_swift_bucket_metadata_from_backend(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn set_swift_bucket_metadata(bucket: String, metadata: SwiftBucketMetadata) -> SwiftStorageResult<()> {
|
||||
set_swift_bucket_metadata_in_backend(bucket, metadata).await
|
||||
}
|
||||
@@ -55,9 +55,9 @@ use super::account::validate_account_access;
|
||||
use super::container::ContainerMapper;
|
||||
use super::object::{ObjectKeyMapper, SwiftObjectOptions as ObjectOptions, head_object};
|
||||
use super::resolve_swift_object_store_handle;
|
||||
use super::storage_api::{ListOperations as _, ObjectOperations as _};
|
||||
use super::{SwiftError, SwiftResult};
|
||||
use rustfs_credentials::Credentials;
|
||||
use rustfs_storage_api::{ListOperations as _, ObjectOperations as _};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use tracing::{debug, error};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user