use super::{Paused, RemovedRecords, Resize};
use crate::config::ByteSize;
pub fn force_pause_consequence(jobs: usize) -> &'static str {
if jobs == 1 {
"cancels its run on GitHub and removes its runner"
} else {
"cancels their runs on GitHub and removes their runners"
}
}
impl Paused {
pub fn line(&self, target: &str) -> String {
if self.stopped.is_empty() {
return format!("{target} paused: it gets no new runners");
}
let stopped: Vec<String> = self.stopped.iter().map(ToString::to_string).collect();
format!("{target} paused; stopped {}", stopped.join(", "))
}
}
pub fn reseed_requested(profile: &str) -> String {
format!("{profile}: reseed requested; it runs once the profile's slots are free")
}
pub fn reseeded(profile: &str, error: Option<&str>) -> String {
match error {
Some(error) => format!("{profile}: reseed failed: {error}"),
None => format!("{profile}: reseeded"),
}
}
impl RemovedRecords {
pub fn line(&self) -> String {
match self.jobs.len() {
0 => "no record removed".to_owned(),
1 => format!("removed 1 record, {} freed", ByteSize(self.bytes)),
count => format!("removed {count} records, {} freed", ByteSize(self.bytes)),
}
}
}
impl Resize {
pub fn written_line(&self, profile: &str) -> String {
let cpus = self
.cpus
.map(|cpus| format!(", {cpus} cpus"))
.unwrap_or_default();
format!(
"{profile}: memory {}, {} slots{cpus} written; the daemon runs with them",
ByteSize(self.memory),
self.slots
)
}
}
#[cfg(test)]
mod tests;