Skip to main content

inferlab_runtime/
plan.rs

1use serde::{Deserialize, Serialize};
2use std::collections::BTreeMap;
3use std::path::PathBuf;
4
5#[derive(Clone, Debug, Deserialize, Serialize)]
6#[serde(tag = "kind", rename_all = "snake_case")]
7pub enum ReadinessPlan {
8    Http {
9        path: String,
10        /// `None` when the server is capture-armed: readiness remains
11        /// unbounded while process exit and interruption still terminate it.
12        timeout_seconds: Option<u64>,
13        attempt_timeout_seconds: u64,
14    },
15    HttpTargetRegistry {
16        readiness_path: String,
17        registry_path: String,
18        targets_field: String,
19        target_url_field: String,
20        target_role_field: String,
21        target_healthy_field: String,
22        target_bootstrap_port_field: String,
23        expected_targets: Vec<TargetRegistryExpectedTarget>,
24        timeout_seconds: Option<u64>,
25        attempt_timeout_seconds: u64,
26    },
27    ProcessAlive {
28        timeout_seconds: Option<u64>,
29        attempt_timeout_seconds: u64,
30    },
31}
32
33#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
34pub struct TargetRegistryExpectedTarget {
35    pub url: String,
36    pub role: String,
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub bootstrap_port: Option<u16>,
39}
40
41#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
42pub struct LaunchFilePlan {
43    pub relative_path: String,
44    pub resolved_path: PathBuf,
45    pub text: String,
46    pub sha256: String,
47}
48
49#[derive(Clone, Debug, Deserialize, Serialize)]
50#[serde(tag = "kind", rename_all = "kebab-case")]
51pub enum LaunchPlan {
52    Local,
53    Ssh { target: String },
54}
55
56#[derive(Clone, Debug, Deserialize, Serialize)]
57pub struct CommandPlan {
58    pub argv: Vec<String>,
59    pub env: BTreeMap<String, String>,
60    /// Variables explicitly rendered by resolution or an integration, as
61    /// distinct from ambient environment composed for local execution.
62    #[serde(default, skip_serializing_if = "Vec::is_empty")]
63    pub explicit_env: Vec<String>,
64    /// Names whose values flow from the launching machine into a
65    /// containerized process without projecting remote values into the plan.
66    #[serde(default, skip_serializing_if = "Vec::is_empty")]
67    pub pass_env: Vec<String>,
68    pub cwd: PathBuf,
69}
70
71impl CommandPlan {
72    /// The per-process runtime directory on the process's own machine,
73    /// `<cwd>/runtime/<record_id>/<process_id>`: an SSH launch lands its
74    /// log and handle files here, and a profiler capture keeps its output
75    /// in a `profiles` subdirectory.
76    #[must_use]
77    pub fn runtime_dir(&self, record_id: &str, process_id: &str) -> PathBuf {
78        self.cwd.join("runtime").join(record_id).join(process_id)
79    }
80}
81
82#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
83pub struct ProcessEndpointPlan {
84    pub host: String,
85    pub port: u16,
86}