feat(event-notifier): improve notification system initialization safety

- Add READY atomic flag to track full initialization status
- Implement initialize_safe and start_safe methods with mutex protection
- Add wait_until_ready function with configurable timeout
- Create initialize_and_start_with_ready_check helper method
- Replace sleep-based waiting with proper readiness checks
- Add safety checks before sending events
- Replace chrono with std::time for time handling
- Update error handling to provide clear initialization status

This change reduces race conditions in multi-threaded environments
and ensures events are only processed when the system is fully ready.
This commit is contained in:
houseme
2025-04-21 13:28:01 +08:00
parent bfc165abe0
commit 3b6397012b
12 changed files with 266 additions and 140 deletions
Generated
+4 -12
View File
@@ -3046,10 +3046,10 @@ dependencies = [
]
[[package]]
name = "dotenv"
version = "0.15.0"
name = "dotenvy"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
[[package]]
name = "dpi"
@@ -7372,8 +7372,7 @@ version = "0.0.1"
dependencies = [
"async-trait",
"axum",
"chrono",
"dotenv",
"dotenvy",
"figment",
"rdkafka",
"reqwest",
@@ -7389,7 +7388,6 @@ dependencies = [
"tracing",
"tracing-subscriber",
"uuid",
"wildmatch",
]
[[package]]
@@ -9639,12 +9637,6 @@ dependencies = [
"rustix 0.38.44",
]
[[package]]
name = "wildmatch"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ce1ab1f8c62655ebe1350f589c61e505cf94d385bc6a12899442d9081e71fd"
[[package]]
name = "winapi"
version = "0.3.9"