haematite-cli 0.21.7

The haematite command: serve a store, its door and Studio, answer MCP, query with jq, and host the store's assistant seat
Documentation
use super::Site;
use crate::door::http::Response;
use serde_json::json;
use std::sync::atomic::Ordering;

pub(in crate::door) fn child_given_up(site: &Site, store: &str) -> Option<Response> {
    let (name, given_up) = site.store_children.get(store)?;
    given_up.load(Ordering::Acquire).then(|| {
        Response::json(
            503,
            &json!({
                "code": "store_child_given_up", "child": name,
                "message": format!("store {store} is unavailable because child {name} was given up")
            }),
        )
    })
}

pub(super) fn store_line(site: &Site, store: &str) -> serde_json::Value {
    if let Some((name, failed)) = site.store_children.get(store)
        && failed.load(Ordering::Acquire)
    {
        json!({"name":store,"given_up":true,"child":name})
    } else {
        json!({"name":store})
    }
}