|
1 | | -use super::with_start_time::StartTime; |
2 | 1 | use crate::agent_control::agent_id::AgentID; |
3 | | -use crate::agent_type::runtime_config::HealthCheckInterval; |
4 | 2 | use crate::event::SubAgentInternalEvent; |
5 | 3 | use crate::event::cancellation::CancellationMessage; |
6 | 4 | use crate::event::channel::{EventConsumer, EventPublisher}; |
7 | | - |
8 | | -use crate::health::with_start_time::HealthWithStartTime; |
| 5 | +use crate::health::with_start_time::{HealthWithStartTime, StartTime}; |
9 | 6 | use crate::k8s; |
10 | 7 | use crate::sub_agent::identity::ID_ATTRIBUTE_NAME; |
11 | 8 | use crate::sub_agent::supervisor::starter::SupervisorStarterError; |
12 | 9 | use crate::utils::thread_context::{NotStartedThreadContext, StartedThreadContext}; |
| 10 | +use duration_str::deserialize_duration; |
| 11 | +use serde::Deserialize; |
13 | 12 | use std::thread::sleep; |
14 | 13 | use std::time::{Duration, SystemTime, SystemTimeError}; |
15 | 14 | use tracing::{debug, error, info_span}; |
| 15 | +use wrapper_with_default::WrapperWithDefault; |
16 | 16 |
|
17 | 17 | const HEALTH_CHECKER_THREAD_NAME: &str = "health_checker"; |
18 | 18 |
|
| 19 | +const DEFAULT_HEALTH_CHECK_INTERVAL: Duration = Duration::from_secs(60); |
| 20 | + |
19 | 21 | pub type StatusTime = SystemTime; |
20 | 22 |
|
| 23 | +#[derive(Debug, Deserialize, Clone, Copy, PartialEq, WrapperWithDefault)] |
| 24 | +#[wrapper_default_value(DEFAULT_HEALTH_CHECK_INTERVAL)] |
| 25 | +pub struct HealthCheckInterval(#[serde(deserialize_with = "deserialize_duration")] Duration); |
| 26 | + |
21 | 27 | #[derive(Clone, Debug, PartialEq)] |
22 | 28 | pub enum Health { |
23 | 29 | Healthy(Healthy), |
@@ -278,7 +284,6 @@ where |
278 | 284 | break; |
279 | 285 | } |
280 | 286 | }; |
281 | | - |
282 | 287 | NotStartedThreadContext::new(HEALTH_CHECKER_THREAD_NAME, callback).start() |
283 | 288 | } |
284 | 289 |
|
|
0 commit comments