Skip to main content

agentic_connect/types/
health.rs

1//! Health check types — Invention 20: Network Sentinel.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6use super::connection::ConnectionId;
7use super::protocol::Protocol;
8
9/// Result of a health probe.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct HealthCheck {
12    pub connection_id: ConnectionId,
13    pub protocol: Protocol,
14    pub host: String,
15    pub port: u16,
16    pub status: HealthStatus,
17    pub latency_ms: Option<f64>,
18    pub message: Option<String>,
19    pub checked_at: DateTime<Utc>,
20}
21
22/// Health status classification.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "lowercase")]
25pub enum HealthStatus {
26    Healthy,
27    Degraded,
28    Unhealthy,
29    Unknown,
30}
31
32/// Service level objective for monitoring.
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct Slo {
35    pub name: String,
36    pub connection_id: ConnectionId,
37    pub max_latency_ms: Option<f64>,
38    pub min_availability_pct: Option<f64>,
39    pub max_error_rate_pct: Option<f64>,
40}
41
42/// Trend data point for monitoring.
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct TrendPoint {
45    pub timestamp: DateTime<Utc>,
46    pub latency_ms: f64,
47    pub success: bool,
48    pub error_type: Option<String>,
49}