mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 21:33:14 +00:00
refactor: prune notify ecstore object alias (#3620)
This commit is contained in:
@@ -17,11 +17,11 @@ use std::sync::Arc;
|
||||
pub(crate) const IAM_CONFIG_ROOT_PREFIX: &str = rustfs_ecstore::config::RUSTFS_CONFIG_PREFIX;
|
||||
|
||||
pub(crate) type IamEcstoreError = rustfs_ecstore::error::Error;
|
||||
pub(crate) type IamConfigObjectInfo = rustfs_ecstore::object_api::ObjectInfo;
|
||||
pub(crate) type IamConfigObjectOptions = rustfs_ecstore::object_api::ObjectOptions;
|
||||
pub(crate) type IamStorageError = rustfs_ecstore::error::StorageError;
|
||||
pub(crate) type IamStorageResult<T> = rustfs_ecstore::error::Result<T>;
|
||||
pub(crate) type IamStore = rustfs_ecstore::store::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::config::com::read_config_no_lock(api, file).await
|
||||
|
||||
@@ -12,5 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(super) type IamObjectInfo = rustfs_ecstore::object_api::ObjectInfo;
|
||||
pub(super) type IamObjectOptions = rustfs_ecstore::object_api::ObjectOptions;
|
||||
use crate::storage_compat::IamStore;
|
||||
|
||||
pub(super) type IamObjectInfo = <IamStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
|
||||
pub(super) type IamObjectOptions = <IamStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
|
||||
|
||||
@@ -12,14 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use rustfs_config::server_config::Config;
|
||||
use rustfs_ecstore::{config, global};
|
||||
|
||||
use crate::event::NotifyObjectInfo;
|
||||
|
||||
type EcstoreObjectInfo = rustfs_ecstore::object_api::ObjectInfo;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum NotifyConfigStoreError {
|
||||
StorageNotAvailable,
|
||||
@@ -49,73 +44,3 @@ where
|
||||
|
||||
Ok(Some(new_config))
|
||||
}
|
||||
|
||||
impl From<EcstoreObjectInfo> for NotifyObjectInfo {
|
||||
fn from(object: EcstoreObjectInfo) -> Self {
|
||||
Self {
|
||||
bucket: object.bucket,
|
||||
name: object.name,
|
||||
size: object.size,
|
||||
etag: object.etag,
|
||||
content_type: object.content_type,
|
||||
user_defined: object
|
||||
.user_defined
|
||||
.iter()
|
||||
.map(|(key, value)| (key.clone(), value.clone()))
|
||||
.collect(),
|
||||
version_id: object.version_id.map(|version_id| version_id.to_string()),
|
||||
mod_time: object
|
||||
.mod_time
|
||||
.and_then(|value| DateTime::<Utc>::from_timestamp(value.unix_timestamp(), value.nanosecond())),
|
||||
restore_expires: object
|
||||
.restore_expires
|
||||
.and_then(|value| DateTime::<Utc>::from_timestamp(value.unix_timestamp(), value.nanosecond())),
|
||||
storage_class: object.storage_class,
|
||||
transitioned_tier: (!object.transitioned_object.tier.is_empty()).then_some(object.transitioned_object.tier),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use rustfs_storage_api::TransitionedObject;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use time::{Duration, OffsetDateTime};
|
||||
|
||||
#[test]
|
||||
fn ecstore_object_info_conversion_preserves_notify_event_fields() {
|
||||
let mod_time = OffsetDateTime::UNIX_EPOCH + Duration::seconds(42);
|
||||
let restore_expires = OffsetDateTime::UNIX_EPOCH + Duration::seconds(1_700_000_000);
|
||||
let mut metadata = HashMap::new();
|
||||
metadata.insert("x-amz-meta-key".to_string(), "value".to_string());
|
||||
|
||||
let converted = NotifyObjectInfo::from(EcstoreObjectInfo {
|
||||
bucket: "bucket".to_string(),
|
||||
name: "object".to_string(),
|
||||
size: 123,
|
||||
etag: Some("etag".to_string()),
|
||||
content_type: Some("text/plain".to_string()),
|
||||
user_defined: Arc::new(metadata),
|
||||
mod_time: Some(mod_time),
|
||||
restore_expires: Some(restore_expires),
|
||||
storage_class: Some("GLACIER".to_string()),
|
||||
transitioned_object: TransitionedObject {
|
||||
tier: "DEEP_ARCHIVE".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
assert_eq!(converted.bucket, "bucket");
|
||||
assert_eq!(converted.name, "object");
|
||||
assert_eq!(converted.size, 123);
|
||||
assert_eq!(converted.etag.as_deref(), Some("etag"));
|
||||
assert_eq!(converted.content_type.as_deref(), Some("text/plain"));
|
||||
assert_eq!(converted.user_defined.get("x-amz-meta-key").map(String::as_str), Some("value"));
|
||||
assert_eq!(converted.mod_time, DateTime::<Utc>::from_timestamp(42, 0));
|
||||
assert_eq!(converted.restore_expires, DateTime::<Utc>::from_timestamp(1_700_000_000, 0));
|
||||
assert_eq!(converted.storage_class.as_deref(), Some("GLACIER"));
|
||||
assert_eq!(converted.transitioned_tier.as_deref(), Some("DEEP_ARCHIVE"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user