feat: integrate event-notifier system with rustfs

- Rename package from rustfs-event-notifier to event-notifier for consistency
- Add shutdown hooks for event notification system in main process
- Handle graceful termination of notification services on server shutdown
- Implement initialization and configuration loading for event notification
- Fix environment variable configuration to properly parse adapter arrays
- Update example code to demonstrate proper configuration usage

This change ensures proper integration between rustfs and the event
notification system, with clean startup and shutdown sequences to prevent
resource leaks during application lifecycle.
This commit is contained in:
houseme
2025-04-22 20:49:39 +08:00
parent e4453adf82
commit 4f347a92c1
3 changed files with 33 additions and 5 deletions
+3 -3
View File
@@ -29,10 +29,10 @@ async fn main() -> Result<(), Box<dyn error::Error>> {
})],
};
// load_config
// event_load_config
// loading configuration from environment variables
let _config = NotifierConfig::load_config(Some("./crates/event-notifier/examples/event.toml".to_string()));
tracing::info!("load_config config: {:?} \n", _config);
let _config = NotifierConfig::event_load_config(Some("./crates/event-notifier/examples/event.toml".to_string()));
tracing::info!("event_load_config config: {:?} \n", _config);
let system = Arc::new(tokio::sync::Mutex::new(NotifierSystem::new(config.clone()).await?));
let adapters = create_adapters(&config.adapters)?;
+2 -2
View File
@@ -102,9 +102,9 @@ impl NotifierConfig {
/// ```
/// use rustfs_event_notifier::NotifierConfig;
///
/// let config = NotifierConfig::load_config(None);
/// let config = NotifierConfig::event_load_config(None);
/// ```
pub fn load_config(config_dir: Option<String>) -> NotifierConfig {
pub fn event_load_config(config_dir: Option<String>) -> NotifierConfig {
let config_dir = if let Some(path) = config_dir {
// If a path is provided, check if it's empty
if path.is_empty() {