wanted: converge a destroyed declaration by tearing the container down
This commit is contained in:
parent
e82a735745
commit
6fd5bc1c4f
2 changed files with 61 additions and 8 deletions
|
|
@ -91,6 +91,11 @@ pub enum AgentState {
|
|||
Up,
|
||||
/// Exists on the hive and is not running.
|
||||
Offline,
|
||||
/// Torn down entirely — the hive runs the destroy template once, then
|
||||
/// this agent drops out of the declared set rather than staying as a
|
||||
/// third steady state. Irreversible: there is no state that brings a
|
||||
/// destroyed agent back short of a fresh deploy.
|
||||
Destroyed,
|
||||
}
|
||||
|
||||
impl AgentState {
|
||||
|
|
@ -103,6 +108,7 @@ impl AgentState {
|
|||
match self {
|
||||
AgentState::Up => "up",
|
||||
AgentState::Offline => "offline",
|
||||
AgentState::Destroyed => "destroyed",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -211,10 +217,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn the_known_states_decode_and_round_trip() {
|
||||
let doc = r#"{"agents":{"a":{"state":"up"},"b":{"state":"offline"}}}"#;
|
||||
let doc =
|
||||
r#"{"agents":{"a":{"state":"up"},"b":{"state":"offline"},"c":{"state":"destroyed"}}}"#;
|
||||
let decoded: HiveWanted = serde_json::from_str(doc).expect("decodes");
|
||||
assert_eq!(decoded.agents["a"].state, AgentState::Up);
|
||||
assert_eq!(decoded.agents["b"].state, AgentState::Offline);
|
||||
assert_eq!(decoded.agents["c"].state, AgentState::Destroyed);
|
||||
assert_eq!(serde_json::to_string(&decoded).expect("serialises"), doc);
|
||||
}
|
||||
|
||||
|
|
@ -253,10 +261,10 @@ mod tests {
|
|||
/// to compile here rather than quietly going untested.
|
||||
#[test]
|
||||
fn as_str_matches_the_serde_spelling() {
|
||||
let every = [AgentState::Up, AgentState::Offline];
|
||||
let every = [AgentState::Up, AgentState::Offline, AgentState::Destroyed];
|
||||
for state in every {
|
||||
match state {
|
||||
AgentState::Up | AgentState::Offline => {}
|
||||
AgentState::Up | AgentState::Offline | AgentState::Destroyed => {}
|
||||
}
|
||||
assert_eq!(
|
||||
serde_json::to_string(&state).expect("serialises"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue