stackless_core/
checkpoint.rs1use serde::{Deserialize, Serialize};
4
5use crate::types::{LogPath, Pid, ProcessStartTime, ProxyHost, TcpPort};
6
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9pub struct StartCheckpoint {
10 pub pid: Pid,
11 pub start_time: ProcessStartTime,
12 #[serde(default, skip_serializing_if = "Option::is_none")]
13 pub command: Option<crate::durable_command::CommandStamp>,
14 pub port: TcpPort,
15 pub hosts: Vec<ProxyHost>,
16 pub log: LogPath,
17}
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[test]
24 fn start_checkpoint_roundtrip() {
25 let original = StartCheckpoint {
26 pid: Pid::from_os(12345),
27 start_time: ProcessStartTime::from_os(1_700_000_000),
28 command: None,
29 port: TcpPort::try_new(8080).unwrap(),
30 hosts: vec![
31 ProxyHost::try_new("api.dev.localhost").unwrap(),
32 ProxyHost::try_new("dev.localhost").unwrap(),
33 ],
34 log: LogPath::try_new("/tmp/state/logs/dev/api.log").unwrap(),
35 };
36 let json = serde_json::to_string(&original).unwrap();
37 let restored: StartCheckpoint = serde_json::from_str(&json).unwrap();
38 assert_eq!(original, restored);
39 assert!(json.contains("\"pid\":12345"));
40 assert!(json.contains("\"port\":8080"));
41 }
42}