mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-21 03:46:37 +00:00
fix(notify): keep live listen events active when disabled (#2952)
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -38,6 +38,20 @@ pub async fn initialize(config: Config) -> Result<(), NotificationError> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize the global notification system only for live in-process consumers.
|
||||
///
|
||||
/// This does not load configured notification targets or bucket rules. It exists so
|
||||
/// ListenBucketNotification clients can receive live events even when external
|
||||
/// notification targets are disabled.
|
||||
pub fn initialize_live_events() -> Result<(), NotificationError> {
|
||||
let system = NotificationSystem::new(Config::new());
|
||||
|
||||
match NOTIFICATION_SYSTEM.set(Arc::new(system)) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(NotificationError::Lifecycle(LifecycleError::AlreadyInitialized)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a handle to the global NotificationSystem instance.
|
||||
/// Return None if the system has not been initialized.
|
||||
pub fn notification_system() -> Option<Arc<NotificationSystem>> {
|
||||
|
||||
@@ -32,7 +32,7 @@ pub mod stream;
|
||||
pub use error::{LifecycleError, NotificationError};
|
||||
pub use event::{Event, EventArgs, EventArgsBuilder};
|
||||
pub use global::{
|
||||
initialize, is_notification_system_initialized, notification_metrics_snapshot, notification_system,
|
||||
initialize, initialize_live_events, is_notification_system_initialized, notification_metrics_snapshot, notification_system,
|
||||
notification_target_metrics, notifier_global,
|
||||
};
|
||||
pub use integration::{NotificationMetricSnapshot, NotificationSystem, NotificationTargetMetricSnapshot};
|
||||
|
||||
Reference in New Issue
Block a user