runnerd_core/api/
results.rs1use super::{Paused, RemovedRecords, Resize};
6use crate::config::ByteSize;
7
8pub fn force_pause_consequence(jobs: usize) -> &'static str {
11 if jobs == 1 {
12 "cancels its run on GitHub and removes its runner"
13 } else {
14 "cancels their runs on GitHub and removes their runners"
15 }
16}
17
18impl Paused {
19 pub fn line(&self, target: &str) -> String {
22 if self.stopped.is_empty() {
23 return format!("{target} paused: it gets no new runners");
24 }
25 let stopped: Vec<String> = self.stopped.iter().map(ToString::to_string).collect();
26 format!("{target} paused; stopped {}", stopped.join(", "))
27 }
28}
29
30pub fn reseed_requested(profile: &str) -> String {
32 format!("{profile}: reseed requested; it runs once the profile's slots are free")
33}
34
35pub fn reseeded(profile: &str, error: Option<&str>) -> String {
37 match error {
38 Some(error) => format!("{profile}: reseed failed: {error}"),
39 None => format!("{profile}: reseeded"),
40 }
41}
42
43impl RemovedRecords {
44 pub fn line(&self) -> String {
46 match self.jobs.len() {
47 0 => "no record removed".to_owned(),
48 1 => format!("removed 1 record, {} freed", ByteSize(self.bytes)),
49 count => format!("removed {count} records, {} freed", ByteSize(self.bytes)),
50 }
51 }
52}
53
54impl Resize {
55 pub fn written_line(&self, profile: &str) -> String {
58 let cpus = self
59 .cpus
60 .map(|cpus| format!(", {cpus} cpus"))
61 .unwrap_or_default();
62 format!(
63 "{profile}: memory {}, {} slots{cpus} written; the daemon runs with them",
64 ByteSize(self.memory),
65 self.slots
66 )
67 }
68}
69
70#[cfg(test)]
71mod tests;