From 5155a3d544e67d4798c719944fc23485972c676f Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 23 Jun 2025 04:15:05 +0800 Subject: [PATCH] fix --- crates/notify/examples/full_demo.rs | 5 ++--- crates/notify/examples/full_demo_one.rs | 5 ++--- crates/notify/src/event.rs | 13 ++++++------- crates/notify/src/global.rs | 2 +- rustfs/src/config/mod.rs | 4 ---- rustfs/src/main.rs | 2 +- rustfs/src/storage/ecfs.rs | 1 - rustfs/src/storage/global.rs | 4 ++++ 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/crates/notify/examples/full_demo.rs b/crates/notify/examples/full_demo.rs index 0cdf50f4..225d0bd0 100644 --- a/crates/notify/examples/full_demo.rs +++ b/crates/notify/examples/full_demo.rs @@ -4,12 +4,11 @@ use rustfs_notify::factory::{ DEFAULT_TARGET, MQTT_BROKER, MQTT_PASSWORD, MQTT_QOS, MQTT_QUEUE_DIR, MQTT_QUEUE_LIMIT, MQTT_TOPIC, MQTT_USERNAME, NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS, WEBHOOK_AUTH_TOKEN, WEBHOOK_ENDPOINT, WEBHOOK_QUEUE_DIR, WEBHOOK_QUEUE_LIMIT, }; -use rustfs_notify::global::notification_system; use rustfs_notify::store::DEFAULT_LIMIT; use rustfs_notify::{init_logger, BucketNotificationConfig, Event, EventName, LogLevel, NotificationError}; +use rustfs_notify::{initialize, notification_system}; use std::time::Duration; use tracing::info; -use tracing_subscriber::util::SubscriberInitExt; #[tokio::main] async fn main() -> Result<(), NotificationError> { @@ -19,7 +18,7 @@ async fn main() -> Result<(), NotificationError> { Some(sys) => sys, None => { let config = Config::new(); - notification_system::initialize(config).await?; + initialize(config).await?; notification_system().expect("Failed to initialize notification system") } }; diff --git a/crates/notify/examples/full_demo_one.rs b/crates/notify/examples/full_demo_one.rs index 2af55a58..28d4b88a 100644 --- a/crates/notify/examples/full_demo_one.rs +++ b/crates/notify/examples/full_demo_one.rs @@ -5,12 +5,11 @@ use rustfs_notify::factory::{ DEFAULT_TARGET, MQTT_BROKER, MQTT_PASSWORD, MQTT_QOS, MQTT_QUEUE_DIR, MQTT_QUEUE_LIMIT, MQTT_TOPIC, MQTT_USERNAME, NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS, WEBHOOK_AUTH_TOKEN, WEBHOOK_ENDPOINT, WEBHOOK_QUEUE_DIR, WEBHOOK_QUEUE_LIMIT, }; -use rustfs_notify::global::notification_system; use rustfs_notify::store::DEFAULT_LIMIT; use rustfs_notify::{init_logger, BucketNotificationConfig, Event, EventName, LogLevel, NotificationError}; +use rustfs_notify::{initialize, notification_system}; use std::time::Duration; use tracing::info; -use tracing_subscriber::util::SubscriberInitExt; #[tokio::main] async fn main() -> Result<(), NotificationError> { @@ -21,7 +20,7 @@ async fn main() -> Result<(), NotificationError> { Some(sys) => sys, None => { let config = Config::new(); - notification_system::initialize(config).await?; + initialize(config).await?; notification_system().expect("Failed to initialize notification system") } }; diff --git a/crates/notify/src/event.rs b/crates/notify/src/event.rs index 22bb630f..829c4f43 100644 --- a/crates/notify/src/event.rs +++ b/crates/notify/src/event.rs @@ -488,13 +488,12 @@ impl Event { s3_metadata.object.etag = args.object.etag.clone(); s3_metadata.object.content_type = args.object.content_type.clone(); // Filter out internal reserved metadata - let user_metadata = args - .object - .user_defined - .iter() - .filter(|&(k, v)| !k.to_lowercase().starts_with("x-amz-meta-internal-")) - .map(|(k, v)| (k.clone(), v.clone())) - .collect::>(); + let mut user_metadata = HashMap::new(); + for (k, v) in &args.object.user_defined.unwrap_or_default() { + if !k.to_lowercase().starts_with("x-amz-meta-internal-") { + user_metadata.insert(k.clone(), v.clone()); + } + } s3_metadata.object.user_metadata = Some(user_metadata); } diff --git a/crates/notify/src/global.rs b/crates/notify/src/global.rs index b2dffe5c..f2b95439 100644 --- a/crates/notify/src/global.rs +++ b/crates/notify/src/global.rs @@ -32,7 +32,7 @@ pub struct Notifier { // Rely on getting an instance of NotificationSystem from the outside. } -impl crate::notifier::Notifier { +impl Notifier { /// Notify an event asynchronously. /// This is the only entry point for all event notifications in the system. pub async fn notify(&self, args: EventArgs) { diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index a720221f..945451df 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -73,10 +73,6 @@ pub struct Opt { #[arg(long, env = "RUSTFS_LICENSE")] pub license: Option, - - /// event notifier config file - #[arg(long, env = "RUSTFS_EVENT_CONFIG")] - pub event_config: Option, } // lazy_static::lazy_static! { diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 856dfdeb..b0695233 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -516,7 +516,7 @@ async fn run(opt: config::Opt) -> Result<()> { // GLOBAL_EVENT_SYS.init(store.clone()).await?; // Initialize event notifier - event::init_event_notifier(opt.event_config).await; + event::init_event_notifier().await; let buckets_list = store .list_bucket(&BucketOptions { diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 066736f6..56bc8cf1 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -66,7 +66,6 @@ use policy::policy::Validator; use query::instance::make_rustfsms; use rustfs_filemeta::headers::RESERVED_METADATA_PREFIX_LOWER; use rustfs_filemeta::headers::{AMZ_DECODED_CONTENT_LENGTH, AMZ_OBJECT_TAGGING}; -use rustfs_notify::EventName; use rustfs_rio::CompressReader; use rustfs_rio::HashReader; use rustfs_rio::Reader; diff --git a/rustfs/src/storage/global.rs b/rustfs/src/storage/global.rs index e55d79ab..a6d7ad58 100644 --- a/rustfs/src/storage/global.rs +++ b/rustfs/src/storage/global.rs @@ -3,6 +3,7 @@ use s3s::{S3Request, S3Response}; use std::collections::HashMap; /// Extract request parameters from S3Request, mainly header information. +#[allow(dead_code)] pub fn extract_req_params(req: &S3Request) -> HashMap { let mut params = HashMap::new(); for (key, value) in req.headers.iter() { @@ -14,6 +15,7 @@ pub fn extract_req_params(req: &S3Request) -> HashMap { } /// Extract response elements from S3Response, mainly header information. +#[allow(dead_code)] pub fn extract_resp_elements(resp: &S3Response) -> HashMap { let mut params = HashMap::new(); for (key, value) in resp.headers.iter() { @@ -25,6 +27,7 @@ pub fn extract_resp_elements(resp: &S3Response) -> HashMap } /// Get host from header information. +#[allow(dead_code)] pub fn get_request_host(headers: &HeaderMap) -> String { headers .get("host") @@ -34,6 +37,7 @@ pub fn get_request_host(headers: &HeaderMap) -> String { } /// Get user-agent from header information. +#[allow(dead_code)] pub fn get_request_user_agent(headers: &HeaderMap) -> String { headers .get("user-agent")