mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-12 16:16:55 +00:00
fix(notify): keep live listen events active when disabled (#2952)
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user