use super::funejson::Value; /// A heartbeat as one check behind a status page component. Late is /// degraded, not down: the job may still ping within its grace time, which is /// what the grace time is for. A new heartbeat has proved nothing either way, /// so it is None rather than a guess. /// /// # Panics /// Panics on an unknown state. pub fn heartbeat_check(state: &str) -> Option { match state { "new" => None, "up" => Some("up".to_string()), "late" => Some("degraded".to_string()), "down" => Some("down".to_string()), other => panic!("unknown heartbeat state: {}", other), } } pub fn fune_vector(args: &[Value]) -> Value { let state = args[0].as_str().to_string(); match heartbeat_check(&state) { Some(s) => Value::str(&s), None => Value::Null, } }