fix(notify): keep live listen events active when disabled (#2952)

Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
Henry Guo
2026-05-14 01:10:14 +08:00
committed by GitHub
parent d4d07095f8
commit c1bcee327c
5 changed files with 68 additions and 3 deletions
+13 -1
View File
@@ -107,9 +107,21 @@ pub async fn init_event_notifier() {
if !enabled {
info!(
target: "rustfs::main::init_event_notifier",
"Notify module is disabled, event notifier initialization is skipped. Set {}=true to enable notify initialization.",
"Notify module is disabled, initializing live event stream support only. Set {}=true to enable notification targets.",
rustfs_config::ENV_NOTIFY_ENABLE
);
if rustfs_notify::notification_system().is_none() {
match rustfs_notify::initialize_live_events() {
Ok(()) => {
install_ecstore_event_dispatch_hook();
info!(
target: "rustfs::main::init_event_notifier",
"Live event stream support initialized successfully."
);
}
Err(e) => error!("Failed to initialize live event stream support: {}", e),
}
}
return;
}
+5 -1
View File
@@ -90,7 +90,7 @@ impl OperationHelper {
/// Create a new OperationHelper for S3 requests.
pub fn new(req: &S3Request<impl Send + Sync>, event: EventName, op: S3Operation) -> Self {
let audit_enabled = is_audit_module_enabled();
let notify_enabled = is_notify_module_enabled();
let notify_enabled = should_build_notification_event(is_notify_module_enabled());
let path = req.uri.path().trim_start_matches('/');
let mut segs = path.splitn(2, '/');
@@ -334,6 +334,10 @@ impl OperationHelper {
}
}
fn should_build_notification_event(notify_module_enabled: bool) -> bool {
notify_module_enabled || rustfs_notify::notification_system().is_some_and(|system| system.has_live_listeners())
}
impl Drop for OperationHelper {
fn drop(&mut self) {
let Self::Enabled(state) = self else {