From 2f6c8be3cb8ed3bb654340def01cff1fafca9610 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2026 06:16:22 +0200 Subject: add the replace kind of remake POST /admin/remakes accepts specs with replace kind, e.g.: { "kind": "replace", "baseHeads": ["..."], "spec": { "document": { "accounts": { ... } }, "rules": [ { "from": "users", "to": "accounts" }, { "from": "users/admin", "drop": true }, { "from": "", "to": "" } ] } } --- src/remake/api.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/remake/api.rs') diff --git a/src/remake/api.rs b/src/remake/api.rs index b17c93b..fc161e6 100644 --- a/src/remake/api.rs +++ b/src/remake/api.rs @@ -20,6 +20,10 @@ //! "replayWindow": {"epochs": 1, "seconds": 604800}, //! "archiveRetention": {"epochs": 2, "seconds": 2592000}, //! "settleSecs": 480 }` +//! +//! `kind` is `compact` (no spec) or `replace`, whose spec is +//! `{ "document": {…store root…}, "rules": [{"from": "a", "to": "b"}, {"from": "c", "drop": true}] }` +//! (see `kind::Replace`). Reports leave the replacement document out (`contentBytes`). use std::time::Duration; @@ -83,6 +87,10 @@ struct Report { phase: Phase, #[serde(flatten)] record: Record, + /// Size of the kind's build input (e.g. a replacement document), which reports + /// leave out. + #[serde(skip_serializing_if = "Option::is_none")] + content_bytes: Option, /// What happened to this remake on the node answering the request. #[serde(skip_serializing_if = "Option::is_none")] local: Option, @@ -114,10 +122,12 @@ fn grace(host: &H) -> u64 { host.dormant_after().as_millis() as u64 } -fn report(host: &H, id: String, record: Record) -> Report { +fn report(host: &H, id: String, mut record: Record) -> Report { + let content = std::mem::take(&mut record.proposal.content); Report { phase: record.phase(unix_millis(), grace(host)), local: host.remake().status(&id), + content_bytes: (!content.is_null()).then(|| content.to_string().len()), id, record, } -- cgit v1.3.1