34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
//! What `bxctl memory sync` prints (M5c spec, section 5): how many items the ledger holds in each
|
|
//! state, and every failed item, oldest first, by its label, never by its text.
|
|
|
|
use crate::honcho::ledger::{Ledger, label};
|
|
|
|
/// The answer without `[honcho]`: not an error.
|
|
pub const NOT_CONFIGURED: &str = "honcho sync: not configured (memoryd.toml has no [honcho])";
|
|
|
|
/// The report of `ledger`: one line of counts, then, when any item failed, a heading and one line
|
|
/// per failed item: its time, its label, its kind, and its HTTP status when it had one.
|
|
pub fn report(ledger: &Ledger) -> String {
|
|
let c = ledger.counts();
|
|
let mut out = format!(
|
|
"honcho sync: {} decided: {} sent, {} waiting, {} failed, {} skipped",
|
|
c.decided, c.sent, c.waiting, c.failed, c.skipped
|
|
);
|
|
let failures = ledger.failures();
|
|
if !failures.is_empty() {
|
|
out.push_str("\nfailed, oldest first:");
|
|
for f in failures {
|
|
out.push_str(&format!(
|
|
"\n {} {} {}",
|
|
f.time.to_rfc3339(),
|
|
label(&f.item),
|
|
f.kind
|
|
));
|
|
if let Some(status) = f.status {
|
|
out.push_str(&format!(" (HTTP {status})"));
|
|
}
|
|
}
|
|
}
|
|
out
|
|
}
|