1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # Health Module
//!
//! TAS-75 Phase 5: Centralized health monitoring and backpressure management.
//!
//! This module provides a cache-first architecture for health status monitoring,
//! replacing the real-time interrogation pattern in `web/state.rs`.
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────┐
//! │ HEALTH MODULE ARCHITECTURE │
//! └─────────────────────────────────────────────────────────────────────┘
//!
//! ┌─────────────────────┐
//! │ StatusEvaluator │ (Background Task)
//! │ - DB health check │
//! │ - Channel check │
//! │ - Queue depth │
//! │ - Backpressure │
//! └──────────┬──────────┘
//! │ writes at interval
//! ▼
//! ┌─────────────────────┐
//! │ HealthStatusCaches │ (Thread-safe)
//! │ - db_status │
//! │ - channel_status │
//! │ - queue_status │
//! │ - backpressure │
//! └──────────┬──────────┘
//! │ reads (non-blocking)
//! ▼
//! ┌─────────────────────┐
//! │ BackpressureChecker│ (Public API)
//! │ - try_check_*() │
//! │ - get_*_status() │
//! └─────────────────────┘
//! ```
//!
//! ## Benefits
//!
//! 1. **Performance**: No database queries in API hot path
//! 2. **Reliability**: Health checks isolated from request handling
//! 3. **Observability**: Clear metrics for evaluation frequency
//! 4. **Testability**: Cache-based design easier to test
//! 5. **Configurability**: Evaluation interval tunable per environment
//!
//! ## Usage
//!
//! ```ignore
//! use tasker_orchestration::health::{HealthStatusCaches, BackpressureChecker};
//!
//! // During bootstrap
//! let caches = HealthStatusCaches::new();
//! let checker = BackpressureChecker::new(caches.clone());
//!
//! // In API handlers (synchronous check)
//! if let Some(error) = checker.try_check_backpressure() {
//! return Err(error);
//! }
//!
//! // Get detailed status for health endpoint
//! let metrics = checker.get_backpressure_metrics().await;
//! ```
pub
pub
pub
pub
pub
pub
pub
// Re-export primary types for convenience
pub use BackpressureChecker;
pub use HealthStatusCaches;
pub use StatusEvaluator;
pub use ;