summaryrefslogtreecommitdiffstats
path: root/src/remake/api.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-21 06:16:22 +0200
committertv <tv@krebsco.de>2026-10-21 06:16:22 +0200
commit61cb2dd609a58bbb51db6de8844e5fe5f1afb67e (patch)
tree4d21ae6b6c9ce2c07391bf5a4e856d51f0068efd /src/remake/api.rs
parentc0f1220e62494805234cf509aad2c1dcf1451667 (diff)
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": "" } ] } }
Diffstat (limited to 'src/remake/api.rs')
-rw-r--r--src/remake/api.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/remake/api.rs b/src/remake/api.rs
index b473a2d..7db7acb 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<usize>,
/// What happened to this remake on the node answering the request.
#[serde(skip_serializing_if = "Option::is_none")]
local: Option<LocalStatus>,
@@ -114,10 +122,12 @@ fn grace<H: Host>(host: &H) -> u64 {
host.dormant_after().as_millis() as u64
}
-fn report<H: Host>(host: &H, id: String, record: Record) -> Report {
+fn report<H: Host>(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,
}