diff --git a/Cargo.lock b/Cargo.lock index addc107db2..f4c261f768 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -706,7 +706,6 @@ dependencies = [ "digest", "hex", "notify", - "notify-debouncer-full", "secrecy", "sha1", "snafu", @@ -3398,15 +3397,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "file-id" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" -dependencies = [ - "windows-sys 0.48.0", -] - [[package]] name = "filetime" version = "0.2.23" @@ -5836,20 +5826,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "notify-debouncer-full" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" -dependencies = [ - "crossbeam-channel", - "file-id", - "log", - "notify", - "parking_lot 0.12.1", - "walkdir", -] - [[package]] name = "ntapi" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index e9d97cfbd2..54354000b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,7 +111,6 @@ meter-core = { git = "https://github.com/GreptimeTeam/greptime-meter.git", rev = mockall = "0.11.4" moka = "0.12" notify = "6.1" -notify-debouncer-full = "0.3" num_cpus = "1.16" once_cell = "1.18" opentelemetry-proto = { git = "https://github.com/waynexia/opentelemetry-rust.git", rev = "33841b38dda79b15f2024952be5f32533325ca02", features = [ diff --git a/src/auth/Cargo.toml b/src/auth/Cargo.toml index d98aee2145..db8c200545 100644 --- a/src/auth/Cargo.toml +++ b/src/auth/Cargo.toml @@ -20,7 +20,6 @@ common-telemetry.workspace = true digest = "0.10" hex = { version = "0.4" } notify.workspace = true -notify-debouncer-full.workspace = true secrecy = { version = "0.8", features = ["serde", "alloc"] } sha1 = "0.10" snafu.workspace = true diff --git a/src/auth/src/user_provider/watch_file_user_provider.rs b/src/auth/src/user_provider/watch_file_user_provider.rs index f93a2f2ed3..6a8f59f87b 100644 --- a/src/auth/src/user_provider/watch_file_user_provider.rs +++ b/src/auth/src/user_provider/watch_file_user_provider.rs @@ -21,7 +21,6 @@ use std::time::Duration; use async_trait::async_trait; use common_telemetry::info; use notify::{EventKind, RecursiveMode, Watcher}; -use notify_debouncer_full::{new_debouncer, DebounceEventResult}; use snafu::ResultExt; use crate::error::{FileWatchSnafu, Result}; @@ -43,11 +42,10 @@ impl WatchFileUserProvider { users: users.clone(), }; - let (tx, rx) = channel::(); - let mut debouncer = new_debouncer(Duration::from_secs(1), None, tx) - .context(FileWatchSnafu { path: "" })?; + let (tx, rx) = channel::>(); + let mut debouncer = + notify::recommended_watcher(tx).context(FileWatchSnafu { path: "" })?; debouncer - .watcher() .watch(Path::new(filepath), RecursiveMode::NonRecursive) .context(FileWatchSnafu { path: filepath })?; @@ -55,11 +53,8 @@ impl WatchFileUserProvider { std::thread::spawn(move || { let _hold = debouncer; while let Ok(res) = rx.recv() { - if let Ok(events) = res { - if events - .iter() - .any(|e| matches!(e.kind, EventKind::Modify(_) | EventKind::Create(_))) - { + if let Ok(event) = res { + if matches!(event.kind, EventKind::Modify(_) | EventKind::Create(_)) { info!("User provider file {} changed", &filepath); if let Ok(credential) = load_credential_from_file(&filepath) { *users.lock().expect("users credential must be valid") = credential;