actr_cli/core/components/
network_validator.rs1use anyhow::Result;
4use async_trait::async_trait;
5
6use super::{ConnectivityStatus, HealthStatus, LatencyInfo, NetworkCheckResult, NetworkValidator};
7
8pub struct DefaultNetworkValidator;
10
11impl DefaultNetworkValidator {
12 pub fn new() -> Self {
13 Self
14 }
15}
16
17impl Default for DefaultNetworkValidator {
18 fn default() -> Self {
19 Self::new()
20 }
21}
22
23#[async_trait]
24impl NetworkValidator for DefaultNetworkValidator {
25 async fn check_connectivity(&self, _service_name: &str) -> Result<ConnectivityStatus> {
26 Ok(ConnectivityStatus {
28 is_reachable: true,
29 response_time_ms: Some(10),
30 error: None,
31 })
32 }
33
34 async fn verify_service_health(&self, _service_name: &str) -> Result<HealthStatus> {
35 Ok(HealthStatus::Healthy)
36 }
37
38 async fn test_latency(&self, _service_name: &str) -> Result<LatencyInfo> {
39 Ok(LatencyInfo {
40 min_ms: 5,
41 max_ms: 20,
42 avg_ms: 10,
43 samples: 3,
44 })
45 }
46
47 async fn batch_check(&self, _service_names: &[String]) -> Result<Vec<NetworkCheckResult>> {
48 let mut results = Vec::new();
49 for _ in _service_names {
50 results.push(NetworkCheckResult {
51 connectivity: ConnectivityStatus {
52 is_reachable: true,
53 response_time_ms: Some(10),
54 error: None,
55 },
56 health: HealthStatus::Healthy,
57 latency: Some(LatencyInfo {
58 min_ms: 5,
59 max_ms: 20,
60 avg_ms: 10,
61 samples: 3,
62 }),
63 });
64 }
65 Ok(results)
66 }
67}