drop notify-debouncer-full dep

Signed-off-by: tison <wander4096@gmail.com>
This commit is contained in:
tison
2024-03-26 14:46:14 +08:00
parent e6ed9ca43e
commit de108e50d0
4 changed files with 5 additions and 36 deletions

24
Cargo.lock generated
View File

@@ -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"

View File

@@ -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 = [

View File

@@ -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

View File

@@ -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::<DebounceEventResult>();
let mut debouncer = new_debouncer(Duration::from_secs(1), None, tx)
.context(FileWatchSnafu { path: "<none>" })?;
let (tx, rx) = channel::<notify::Result<notify::Event>>();
let mut debouncer =
notify::recommended_watcher(tx).context(FileWatchSnafu { path: "<none>" })?;
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;