mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-16 17:20:33 +00:00
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:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -7452,7 +7452,7 @@ dependencies = [
|
||||
"rmp-serde",
|
||||
"rust-embed",
|
||||
"rustfs-config",
|
||||
"rustfs-event-notifier",
|
||||
"rustfs-event",
|
||||
"rustfs-obs",
|
||||
"rustfs-utils",
|
||||
"rustls 0.23.27",
|
||||
@@ -7490,7 +7490,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustfs-event-notifier"
|
||||
name = "rustfs-event"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
|
||||
@@ -7,7 +7,7 @@ members = [
|
||||
"common/protos", # Protocol buffer definitions
|
||||
"common/workers", # Worker thread pools and task scheduling
|
||||
"crates/config", # Configuration management
|
||||
"crates/event-notifier", # Event notification system
|
||||
"crates/event", # Event notification system
|
||||
"crates/obs", # Observability utilities
|
||||
"crates/utils", # Utility functions and helpers
|
||||
"crypto", # Cryptography and security features
|
||||
@@ -51,7 +51,7 @@ rustfs = { path = "./rustfs", version = "0.0.1" }
|
||||
zip = { path = "./crates/zip", version = "0.0.1" }
|
||||
rustfs-config = { path = "./crates/config", 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" }
|
||||
workers = { path = "./common/workers", version = "0.0.1" }
|
||||
tokio-tar = "0.3.1"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rustfs-event-notifier"
|
||||
name = "rustfs-event"
|
||||
edition.workspace = true
|
||||
license.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,
|
||||
};
|
||||
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
|
||||
for _ in 0..50 {
|
||||
// wait up to 5 seconds
|
||||
if rustfs_event_notifier::is_ready() {
|
||||
if rustfs_event::is_ready() {
|
||||
return Ok(());
|
||||
}
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
|
||||
@@ -107,7 +107,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.build()
|
||||
.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);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// 优雅关闭通知系统
|
||||
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);
|
||||
} else {
|
||||
println!("the notification system has been closed safely");
|
||||
@@ -1,7 +1,7 @@
|
||||
use rustfs_event_notifier::create_adapters;
|
||||
use rustfs_event_notifier::NotifierSystem;
|
||||
use rustfs_event_notifier::{AdapterConfig, NotifierConfig, WebhookConfig};
|
||||
use rustfs_event_notifier::{Bucket, Event, Identity, Metadata, Name, Object, Source};
|
||||
use rustfs_event::create_adapters;
|
||||
use rustfs_event::NotifierSystem;
|
||||
use rustfs_event::{AdapterConfig, NotifierConfig, WebhookConfig};
|
||||
use rustfs_event::{Bucket, Event, Identity, Metadata, Name, Object, Source};
|
||||
use std::collections::HashMap;
|
||||
use std::error;
|
||||
use std::sync::Arc;
|
||||
@@ -100,7 +100,7 @@ impl NotifierConfig {
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use rustfs_event_notifier::NotifierConfig;
|
||||
/// use rustfs_event::NotifierConfig;
|
||||
///
|
||||
/// let config = NotifierConfig::event_load_config(None);
|
||||
/// ```
|
||||
@@ -1,6 +1,6 @@
|
||||
use rustfs_event_notifier::{AdapterConfig, NotifierSystem, WebhookConfig};
|
||||
use rustfs_event_notifier::{Bucket, Event, EventBuilder, Identity, Metadata, Name, Object, Source};
|
||||
use rustfs_event_notifier::{ChannelAdapter, WebhookAdapter};
|
||||
use rustfs_event::{AdapterConfig, NotifierSystem, WebhookConfig};
|
||||
use rustfs_event::{Bucket, Event, EventBuilder, Identity, Metadata, Name, Object, Source};
|
||||
use rustfs_event::{ChannelAdapter, WebhookAdapter};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -67,7 +67,7 @@ async fn test_webhook_adapter() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_notification_system() {
|
||||
let config = rustfs_event_notifier::NotifierConfig {
|
||||
let config = rustfs_event::NotifierConfig {
|
||||
store_path: "./test_events".to_string(),
|
||||
channel_capacity: 100,
|
||||
adapters: vec![AdapterConfig::Webhook(WebhookConfig {
|
||||
@@ -53,7 +53,7 @@ protos.workspace = true
|
||||
query = { workspace = true }
|
||||
rmp-serde.workspace = true
|
||||
rustfs-config = { workspace = true }
|
||||
rustfs-event-notifier = { workspace = true }
|
||||
rustfs-event = { workspace = true }
|
||||
rustfs-obs = { workspace = true }
|
||||
rustfs-utils = { workspace = true, features = ["full"] }
|
||||
rustls.workspace = true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rustfs_event_notifier::NotifierConfig;
|
||||
use rustfs_event::NotifierConfig;
|
||||
use tracing::{error, info, instrument};
|
||||
|
||||
#[instrument]
|
||||
@@ -8,7 +8,7 @@ pub(crate) async fn init_event_notifier(notifier_config: Option<String>) {
|
||||
info!("event_config is not empty");
|
||||
tokio::spawn(async move {
|
||||
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 {
|
||||
error!("Failed to initialize event notifier: {}", e);
|
||||
} else {
|
||||
|
||||
@@ -562,9 +562,9 @@ async fn run(opt: config::Opt) -> Result<()> {
|
||||
state_manager.update(ServiceState::Stopping);
|
||||
|
||||
// Stop the notification system
|
||||
if rustfs_event_notifier::is_ready() {
|
||||
if rustfs_event::is_ready() {
|
||||
// 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::from_string(err.to_string())
|
||||
})?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rustfs_event_notifier::{Event, Metadata};
|
||||
use rustfs_event::{Event, Metadata};
|
||||
|
||||
/// Create a new metadata object
|
||||
#[allow(dead_code)]
|
||||
@@ -13,5 +13,5 @@ pub(crate) fn create_metadata() -> Metadata {
|
||||
/// Create a new event object
|
||||
#[allow(dead_code)]
|
||||
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())
|
||||
}
|
||||
|
||||
@@ -82,6 +82,6 @@ if [ -n "$1" ]; then
|
||||
fi
|
||||
|
||||
# 启动 webhook 服务器
|
||||
#cargo run --example webhook -p rustfs-event-notifier &
|
||||
#cargo run --example webhook -p rustfs-event &
|
||||
# 启动主服务
|
||||
cargo run --bin rustfs
|
||||
Reference in New Issue
Block a user