Skip to main content

zlayer_types/api/
health.rs

1//! Health check API DTOs.
2
3use serde::{Deserialize, Serialize};
4use utoipa::ToSchema;
5
6/// Health check response
7#[derive(Debug, Serialize, Deserialize, ToSchema)]
8pub struct HealthResponse {
9    /// Service status
10    pub status: String,
11    /// Service version
12    pub version: String,
13    /// Uptime in seconds
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub uptime_secs: Option<u64>,
16    /// Container runtime name (e.g. "youki", "mac-sandbox", "docker")
17    #[serde(default = "default_runtime_name")]
18    pub runtime_name: String,
19}
20
21/// Platform-based default runtime name.
22///
23/// On Linux the bundled libcontainer runtime ("youki") is preferred;
24/// on macOS the sandbox runtime is tried first; Docker is the common fallback.
25#[must_use]
26pub fn default_runtime_name() -> String {
27    if cfg!(target_os = "linux") {
28        "youki".to_string()
29    } else if cfg!(target_os = "macos") {
30        "mac-sandbox".to_string()
31    } else {
32        "auto".to_string()
33    }
34}