feat(protocol): Waiting state and WaitInfo on StatusDetail
This commit is contained in:
@@ -20,6 +20,15 @@ pub struct StatusDetail {
|
||||
#[serde(flatten)]
|
||||
pub summary: ServerSummary,
|
||||
pub recent_transitions: Vec<StateTransition>,
|
||||
#[serde(default)]
|
||||
pub wait_for: Option<WaitInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct WaitInfo {
|
||||
pub description: String,
|
||||
pub elapsed_secs: u64,
|
||||
pub timeout_secs: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ServerState {
|
||||
Stopped,
|
||||
Waiting,
|
||||
Starting,
|
||||
Running,
|
||||
Restarting,
|
||||
@@ -28,4 +29,15 @@ mod tests {
|
||||
let s: ServerState = serde_json::from_str("\"failed\"").unwrap();
|
||||
assert_eq!(s, ServerState::Failed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn waiting_state_round_trips_as_json() {
|
||||
let json = serde_json::to_string(&ServerState::Waiting).unwrap();
|
||||
|
||||
assert_eq!(json, "\"waiting\"");
|
||||
|
||||
let back: ServerState = serde_json::from_str(&json).unwrap();
|
||||
|
||||
assert_eq!(back, ServerState::Waiting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,7 @@ async fn status(reg: &Registry, name: &str) -> Result<StatusDetail, ApiError> {
|
||||
last_exit: s.last_exit,
|
||||
},
|
||||
recent_transitions: Vec::new(),
|
||||
wait_for: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user