feat: rename crate from rustfs-event-notifier to rustfs-event

This change simplifies the crate name to better reflect its core functionality
as the event handling system for RustFS. The renamed package maintains all
existing functionality while improving naming consistency across the project.

- Updated all imports and references to use the new crate name
- Maintained API compatibility with existing implementations
- Updated tests to reflect the name change
This commit is contained in:
houseme
2025-05-19 17:23:17 +08:00
parent 791780dd68
commit c6de1ae994
27 changed files with 27 additions and 27 deletions
Generated
+2 -2
View File
@@ -7452,7 +7452,7 @@ dependencies = [
"rmp-serde", "rmp-serde",
"rust-embed", "rust-embed",
"rustfs-config", "rustfs-config",
"rustfs-event-notifier", "rustfs-event",
"rustfs-obs", "rustfs-obs",
"rustfs-utils", "rustfs-utils",
"rustls 0.23.27", "rustls 0.23.27",
@@ -7490,7 +7490,7 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rustfs-event-notifier" name = "rustfs-event"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"async-trait", "async-trait",
+2 -2
View File
@@ -7,7 +7,7 @@ members = [
"common/protos", # Protocol buffer definitions "common/protos", # Protocol buffer definitions
"common/workers", # Worker thread pools and task scheduling "common/workers", # Worker thread pools and task scheduling
"crates/config", # Configuration management "crates/config", # Configuration management
"crates/event-notifier", # Event notification system "crates/event", # Event notification system
"crates/obs", # Observability utilities "crates/obs", # Observability utilities
"crates/utils", # Utility functions and helpers "crates/utils", # Utility functions and helpers
"crypto", # Cryptography and security features "crypto", # Cryptography and security features
@@ -51,7 +51,7 @@ rustfs = { path = "./rustfs", version = "0.0.1" }
zip = { path = "./crates/zip", version = "0.0.1" } zip = { path = "./crates/zip", version = "0.0.1" }
rustfs-config = { path = "./crates/config", version = "0.0.1" } rustfs-config = { path = "./crates/config", version = "0.0.1" }
rustfs-obs = { path = "crates/obs", version = "0.0.1" } rustfs-obs = { path = "crates/obs", version = "0.0.1" }
rustfs-event-notifier = { path = "crates/event-notifier", version = "0.0.1" } rustfs-event = { path = "crates/event", version = "0.0.1" }
rustfs-utils = { path = "crates/utils", version = "0.0.1" } rustfs-utils = { path = "crates/utils", version = "0.0.1" }
workers = { path = "./common/workers", version = "0.0.1" } workers = { path = "./common/workers", version = "0.0.1" }
tokio-tar = "0.3.1" tokio-tar = "0.3.1"
@@ -1,5 +1,5 @@
[package] [package]
name = "rustfs-event-notifier" name = "rustfs-event"
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
repository.workspace = true repository.workspace = true
@@ -1,4 +1,4 @@
use rustfs_event_notifier::{ use rustfs_event::{
AdapterConfig, Bucket, Error as NotifierError, Event, Identity, Metadata, Name, NotifierConfig, Object, Source, WebhookConfig, AdapterConfig, Bucket, Error as NotifierError, Event, Identity, Metadata, Name, NotifierConfig, Object, Source, WebhookConfig,
}; };
use std::collections::HashMap; use std::collections::HashMap;
@@ -19,12 +19,12 @@ async fn setup_notification_system() -> Result<(), NotifierError> {
})], })],
}; };
rustfs_event_notifier::initialize(config).await?; rustfs_event::initialize(config).await?;
// wait for the system to be ready // wait for the system to be ready
for _ in 0..50 { for _ in 0..50 {
// wait up to 5 seconds // wait up to 5 seconds
if rustfs_event_notifier::is_ready() { if rustfs_event::is_ready() {
return Ok(()); return Ok(());
} }
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
@@ -107,7 +107,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.build() .build()
.expect("failed to create event"); .expect("failed to create event");
if let Err(e) = rustfs_event_notifier::send_event(event).await { if let Err(e) = rustfs_event::send_event(event).await {
eprintln!("send event failed:{}", e); eprintln!("send event failed:{}", e);
} }
@@ -122,7 +122,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 优雅关闭通知系统 // 优雅关闭通知系统
println!("turn off the notification system"); println!("turn off the notification system");
if let Err(e) = rustfs_event_notifier::shutdown().await { if let Err(e) = rustfs_event::shutdown().await {
eprintln!("An error occurred while shutting down the notification system:{}", e); eprintln!("An error occurred while shutting down the notification system:{}", e);
} else { } else {
println!("the notification system has been closed safely"); println!("the notification system has been closed safely");
@@ -1,7 +1,7 @@
use rustfs_event_notifier::create_adapters; use rustfs_event::create_adapters;
use rustfs_event_notifier::NotifierSystem; use rustfs_event::NotifierSystem;
use rustfs_event_notifier::{AdapterConfig, NotifierConfig, WebhookConfig}; use rustfs_event::{AdapterConfig, NotifierConfig, WebhookConfig};
use rustfs_event_notifier::{Bucket, Event, Identity, Metadata, Name, Object, Source}; use rustfs_event::{Bucket, Event, Identity, Metadata, Name, Object, Source};
use std::collections::HashMap; use std::collections::HashMap;
use std::error; use std::error;
use std::sync::Arc; use std::sync::Arc;
@@ -100,7 +100,7 @@ impl NotifierConfig {
/// ///
/// # Example /// # Example
/// ``` /// ```
/// use rustfs_event_notifier::NotifierConfig; /// use rustfs_event::NotifierConfig;
/// ///
/// let config = NotifierConfig::event_load_config(None); /// let config = NotifierConfig::event_load_config(None);
/// ``` /// ```
@@ -1,6 +1,6 @@
use rustfs_event_notifier::{AdapterConfig, NotifierSystem, WebhookConfig}; use rustfs_event::{AdapterConfig, NotifierSystem, WebhookConfig};
use rustfs_event_notifier::{Bucket, Event, EventBuilder, Identity, Metadata, Name, Object, Source}; use rustfs_event::{Bucket, Event, EventBuilder, Identity, Metadata, Name, Object, Source};
use rustfs_event_notifier::{ChannelAdapter, WebhookAdapter}; use rustfs_event::{ChannelAdapter, WebhookAdapter};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
@@ -67,7 +67,7 @@ async fn test_webhook_adapter() {
#[tokio::test] #[tokio::test]
async fn test_notification_system() { async fn test_notification_system() {
let config = rustfs_event_notifier::NotifierConfig { let config = rustfs_event::NotifierConfig {
store_path: "./test_events".to_string(), store_path: "./test_events".to_string(),
channel_capacity: 100, channel_capacity: 100,
adapters: vec![AdapterConfig::Webhook(WebhookConfig { adapters: vec![AdapterConfig::Webhook(WebhookConfig {
+1 -1
View File
@@ -53,7 +53,7 @@ protos.workspace = true
query = { workspace = true } query = { workspace = true }
rmp-serde.workspace = true rmp-serde.workspace = true
rustfs-config = { workspace = true } rustfs-config = { workspace = true }
rustfs-event-notifier = { workspace = true } rustfs-event = { workspace = true }
rustfs-obs = { workspace = true } rustfs-obs = { workspace = true }
rustfs-utils = { workspace = true, features = ["full"] } rustfs-utils = { workspace = true, features = ["full"] }
rustls.workspace = true rustls.workspace = true
+2 -2
View File
@@ -1,4 +1,4 @@
use rustfs_event_notifier::NotifierConfig; use rustfs_event::NotifierConfig;
use tracing::{error, info, instrument}; use tracing::{error, info, instrument};
#[instrument] #[instrument]
@@ -8,7 +8,7 @@ pub(crate) async fn init_event_notifier(notifier_config: Option<String>) {
info!("event_config is not empty"); info!("event_config is not empty");
tokio::spawn(async move { tokio::spawn(async move {
let config = NotifierConfig::event_load_config(notifier_config); let config = NotifierConfig::event_load_config(notifier_config);
let result = rustfs_event_notifier::initialize(config).await; let result = rustfs_event::initialize(config).await;
if let Err(e) = result { if let Err(e) = result {
error!("Failed to initialize event notifier: {}", e); error!("Failed to initialize event notifier: {}", e);
} else { } else {
+2 -2
View File
@@ -562,9 +562,9 @@ async fn run(opt: config::Opt) -> Result<()> {
state_manager.update(ServiceState::Stopping); state_manager.update(ServiceState::Stopping);
// Stop the notification system // Stop the notification system
if rustfs_event_notifier::is_ready() { if rustfs_event::is_ready() {
// stop event notifier // stop event notifier
rustfs_event_notifier::shutdown().await.map_err(|err| { rustfs_event::shutdown().await.map_err(|err| {
error!("Failed to shut down the notification system: {}", err); error!("Failed to shut down the notification system: {}", err);
Error::from_string(err.to_string()) Error::from_string(err.to_string())
})?; })?;
+2 -2
View File
@@ -1,4 +1,4 @@
use rustfs_event_notifier::{Event, Metadata}; use rustfs_event::{Event, Metadata};
/// Create a new metadata object /// Create a new metadata object
#[allow(dead_code)] #[allow(dead_code)]
@@ -13,5 +13,5 @@ pub(crate) fn create_metadata() -> Metadata {
/// Create a new event object /// Create a new event object
#[allow(dead_code)] #[allow(dead_code)]
pub(crate) async fn send_event(event: Event) -> Result<(), Box<dyn std::error::Error>> { pub(crate) async fn send_event(event: Event) -> Result<(), Box<dyn std::error::Error>> {
rustfs_event_notifier::send_event(event).await.map_err(|e| e.into()) rustfs_event::send_event(event).await.map_err(|e| e.into())
} }
+1 -1
View File
@@ -82,6 +82,6 @@ if [ -n "$1" ]; then
fi fi
# 启动 webhook 服务器 # 启动 webhook 服务器
#cargo run --example webhook -p rustfs-event-notifier & #cargo run --example webhook -p rustfs-event &
# 启动主服务 # 启动主服务
cargo run --bin rustfs cargo run --bin rustfs