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 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 #[serde(default, skip_serializing_if = "Vec::is_empty")]
63 pub explicit_env: Vec<String>,
64 #[serde(default, skip_serializing_if = "Vec::is_empty")]
67 pub pass_env: Vec<String>,
68 pub cwd: PathBuf,
69}
70
71impl CommandPlan {
72 #[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}