use serde::{Deserialize, Serialize};
mod actions;
mod admission;
mod archives;
mod attention;
mod budget;
mod control;
mod disk;
mod events;
mod figure;
mod insights;
mod jobs;
mod labels;
mod queue;
mod records;
mod results;
mod savings;
mod sizing;
mod slots;
mod stats;
mod storage;
mod tone;
mod units;
pub use actions::{
ActionAnswer, ActionOutcome, ActionPreview, ActionQuery, ActionRefusal, ActionResult,
ActionTarget, CONFIRM_SECS, JOB_ACTIONS_CHECK, JobAction, JobActions, PreviewFacts,
RerunRefused, RunSeen, SIBLINGS_MAX, Superseded, UnknownCause, actions_in_flight,
actions_no_run, actions_not_configured, actions_off,
};
pub use admission::{Admission, AdmissionPolicy, Basis, CpuAdmission, JobPeak, cores, cpus};
pub use archives::{ActionArchives, ArchiveFailure, ArchiveFailureKind};
pub use attention::{
ATTENTION_MAX, Attention, AttentionItem, AttentionKind, Fix, Subject, attention_items,
};
pub use budget::{
BudgetParts, ClosedKind, ClosedPart, FreePart, HeldKind, HeldPart, HostFigure, Reading,
SlotForm, SlotPart, SlotReading,
};
pub use control::{
Busy, Check, CheckCount, CheckStatus, ConfigCheck, ConfigFile, Doctor, DoctorQuery,
DoctorState, DoctorSummary, PauseQuery, Paused, ReplaceQuery, RunningJob,
};
pub use disk::{
Commits, DiskWrites, DiskWritten, DriveShare, DriveShares, DriveWrites, JobWrites, Measure,
ShareOwner, WriteSection, WriteTop,
};
pub use events::{Event, EventEnvelope, EventQuery, RunnerFailure};
pub use figure::LabelledFigure;
pub use insights::{
AutoNote, CauseWait, Delivery, Digest, HostHazard, HostSpan, INSIGHT_DAYS, INSIGHT_DAYS_MAX,
Insight, InsightFigure, InsightKind, Insights, InsightsHeading, InsightsQuery, LongWait,
Notification, NotifyEvent, NotifyTest, NotifyTestQuery, Priority, ProfileQueue,
RepositoryWaits, RunLink, Severity, WaitFigure, WaitSpread, WeekWaits,
};
#[cfg(feature = "host")]
pub(crate) use jobs::SAMPLE_GAP_INTERVALS;
#[cfg(feature = "host")]
pub(crate) use jobs::TITLE_SOURCE_MAX;
pub use jobs::{
Activity, ActivityQuery, Bucket, BuildCacheCounts, BuildCacheStats, CacheHistory,
CacheHistoryQuery, CacheKind, CacheSize, CacheVolume, Caches, ChartLine, ChartLineKind,
ChartLines, FailureCause, Holder, HostMemory, HostSample, HostSampleQuery, HostSamples, Job,
JobMetrics, JobPage, JobQuery, JobRunner, JobState, JobSummary, JobTitle, Limit, LimitSource,
Limits, LogQuery, LogSummary, Milestone, Outcome, OutcomeKind, Phase, PhaseKind, Pressure,
RunComparison, RunnerProbe, Sample, SampleSeries, SampleUsage, Started, Stats, StatsQuery,
StatsRow, Step, Swap, Timeline, Total, host_margin, job_title,
};
pub use jobs::{
BarEnd, Baseline, BaselineRead, COMPARE_STEP_BYTES, COMPARE_STEPS_MAX, ChangeKind,
CompareQuery, ComparedSteps, FigureDelta, FigureKind, Gap, GapKind, JOB_LABELS_MAX,
JOB_SEARCH_MAX, JOB_TEXT_MAX, JOBS_PAGE_BYTES, JOBS_PAGE_DEFAULT, JOBS_PAGE_MAX, JobComparison,
JobList, JobOrder, JobRange, JobSort, Lane, RecordFilter, RecordMark, RunnerSpan, SlotKey,
SlotTimeline, SlottedBar, SlottedRunner, SortOrder, Span, StepDelta, StepMatch, StepUsage,
TIMELINE_BARS_MAX, TIMELINE_DEFAULT, TIMELINE_WINDOW_MAX, TimelineBar, TimelineQuery,
TimelineRows, Unavailable, row_bytes,
};
pub use jobs::{
Color, FailureSummary, LINE_BYTES_MAX, LINES_DEFAULT, LINES_MAX, LineKind, LineRange, LineRead,
LogEvidence, LogGroup, LogLinesQuery, LogMark, LogNeedle, LogOutline, LogSearch,
LogSearchQuery, MarkKind, OutlineChange, OutlineParts, Outliner, RUNS_MAX, Run,
SEARCH_QUERY_MAX, SavedOutline, Search, StepLines, StepLog, StoredLine, StoredLog, StyledLine,
};
pub use labels::{Column, Feature, JOBS_HEADING, NOT_SUPPORTED, Section, View};
pub use queue::{HostWait, WaitCause};
pub use records::{
Record, RecordLimits, RecordNote, RecordRemoval, Records, RemoveRecordsQuery, RemovedRecords,
SHELL_PROTOCOL, ShellQuery,
};
pub use results::{force_pause_consequence, reseed_outcome, reseed_requested, reseeded};
pub use savings::{
Period, PricedRun, PricedRunner, Pricing, PricingHistory, SELF_HOSTED_RATE, SavedWindow,
Savings, Sku, Usd, Visibility, billed_minutes, reads_since,
};
pub use sizing::{
Advice, AutoPlan, GRANULE, JobSizing, MemoryBound, MemoryHold, Need, PAGE_CACHE_ROOM, Peaks,
ProfilePlan, ProfileSizing, Resize, RevertCause, SAMPLE_INTERVAL, SLOT_DISK, Sizing,
SizingChange, SizingHold, SizingQuery, SizingRefused, SizingRevert, Spread, Starts, need,
period, sampled_note,
};
pub use slots::{Figure, Health, HealthKind, SlotState};
pub use stats::StatsSummary;
pub use storage::{
ACTIONS_CACHE, BUILD_CACHE_TOOLS, BuildCacheActivity, CacheLimit, RECORDS_NEAR_FULL,
RecordState, actions_cache_place, records_check, records_near_full,
};
pub use tone::{Tone, Toned};
pub(crate) use units::days_from_civil;
pub use units::{ago, cores_used, cpu_time, duration, in_cores};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", tag = "kind")]
pub enum Principal {
LocalOwner {
uid: u32,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Status {
pub version: String,
pub shutting_down: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub stopping: Option<Stopping>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub github_limited_until: Option<u64>,
pub budget: Budget,
pub profiles: Vec<ProfileStatus>,
pub repositories: Vec<RepositoryStatus>,
pub queued: Vec<QueuedJob>,
#[serde(default)]
pub job_actions: JobActions,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub action_archives: Option<ActionArchives>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Budget {
pub slice: String,
pub memory_max: Option<u64>,
pub memory_in_use: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pooled: Option<Pooled>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub counted: Option<Counted>,
pub admission: AdmissionPolicy,
pub held: bool,
pub mirror_memory: u64,
pub seed_memory: Vec<SeedMemory>,
pub shell_memory: Vec<ShellMemory>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub host: Option<HostBudget>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cpu: Option<CpuBudget>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub slice_cpus: Option<u64>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct Pooled {
pub credit: u64,
pub counted: u64,
pub runners: u64,
}
pub const GROWTH_WINDOW: std::time::Duration = std::time::Duration::from_mins(10);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct Counted {
pub used: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kept: Option<u64>,
pub jobs: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub brake: Option<CountBrake>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", tag = "kind")]
pub enum CountBrake {
Grew {
grew: u64,
kept: u64,
until: u64,
},
Restarted {
until: u64,
},
Guard {
#[serde(default, skip_serializing_if = "Option::is_none")]
until: Option<u64>,
},
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HostBudget {
pub memory: HostMemory,
pub limit: u64,
pub spare: u64,
pub stalled: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub credit: Option<HostCredit>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct HostCredit {
pub bytes: u64,
pub used: u64,
}
impl HostBudget {
pub fn short_of(&self, needs: u64) -> bool {
let room = self.memory.room();
self.stalled || needs > room || room < host_margin(self.memory.grown())
}
pub fn counts(&self, reserved: u64) -> u64 {
reserved.saturating_sub(self.credit.map_or(0, |credit| credit.bytes))
}
pub fn growth_clause(&self, reserved: u64) -> Option<String> {
let credit = self.credit?;
let counts = self.counts(reserved);
Some(format!(
"it uses {} and keeps {} for growth",
crate::config::ByteSize(credit.used.min(counts)),
crate::config::ByteSize(counts.saturating_sub(credit.used))
))
}
}
fn host_reason(needs: u64, free: u64, host: Option<&HostBudget>, reserved: u64) -> String {
let size = |bytes: u64| crate::config::ByteSize(bytes).to_string();
if let Some(host) = host.filter(|host| !host.short_of(needs)) {
if let Some(growth) = host.growth_clause(reserved) {
return format!(
"The host has {}, but what runs may still grow into it: {growth}; needs {}, {} is free",
host.memory.available_line(),
size(needs),
size(free)
);
}
return format!(
"The host has {}, but what runs may still grow into it: needs {}; {} of the {} it leaves the slice is free",
host.memory.available_line(),
size(needs),
size(free),
size(host.limit)
);
}
let reason = if host.is_some_and(|host| host.stalled) {
"The host is short of memory: its programs stall waiting for it, so nothing starts"
.to_owned()
} else {
format!(
"The host is short of memory: needs {}; the host has {} to spare",
size(needs),
size(free)
)
};
match host {
Some(host) => format!("{reason}; {}", host.memory.outside_line()),
None => reason,
}
}
pub fn percent(hundredths: u32) -> String {
let whole = hundredths / 100;
match hundredths % 100 / 10 {
0 => format!("{whole}%"),
tenth => format!("{whole}.{tenth}%"),
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct CpuBudget {
pub cpus: u64,
pub budget: u64,
pub in_use: u64,
pub held: bool,
}
impl CpuBudget {
pub fn line(&self) -> String {
let mut line = format!(
"CPU {} of {} CPUs reserved",
cores(self.in_use),
cores(self.budget)
);
if self.held {
line.push_str("; a job waits for CPU");
}
line
}
}
impl Budget {
pub fn admission_note(&self) -> Option<&'static str> {
match (self.admission, self.held) {
(AdmissionPolicy::Caps, _) => None,
(AdmissionPolicy::Measured, false) => Some("by predicted peaks"),
(AdmissionPolicy::Measured, true) => Some(
"by predicted peaks; the slice is past 90% of its MemoryMax, so no runner starts",
),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ShellMemory {
pub job: u64,
pub memory: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SeedMemory {
pub profile: String,
pub memory: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProfileStatus {
pub name: String,
pub image: String,
pub cpus: u32,
pub memory: u64,
pub reseeding: bool,
pub slots: Vec<SlotStatus>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SlotStatus {
pub slot: usize,
pub runner: Option<RunnerStatus>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RunnerStatus {
pub repository: String,
pub name: String,
pub runner_id: u64,
pub container: String,
pub busy: bool,
pub started_at: u64,
pub reserved: u64,
pub warm: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RepositoryStatus {
pub name: String,
pub pools: Vec<PoolStatus>,
pub paused: bool,
pub queued_jobs: usize,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub listing: Option<ListingFailure>,
#[serde(default)]
pub queue: QueueShown,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub rerun_refused: Option<RerunRefused>,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum QueueShown {
Listed,
Unlisted,
#[default]
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ListingFailure {
pub since: u64,
pub problem: ListingProblem,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", tag = "kind")]
pub enum ListingProblem {
NoToken,
Unauthorized,
Refused {
status: u16,
},
Failed {
status: u16,
},
Unreachable,
Unexpected,
#[serde(other)]
Unknown,
}
impl ListingProblem {
pub fn is_token(&self) -> bool {
matches!(self, ListingProblem::NoToken | ListingProblem::Unauthorized)
}
}
impl ListingFailure {
pub fn line(&self, repository: &str) -> String {
format!(
"Cannot list {repository}'s queued jobs: {}",
self.problem.why()
)
}
}
impl ListingProblem {
pub fn why(&self) -> String {
match self {
ListingProblem::NoToken => "runnerd has no GitHub token".to_owned(),
ListingProblem::Unauthorized => "GitHub refuses runnerd's token (401)".to_owned(),
ListingProblem::Refused { status: 403 } => {
"GitHub answers 403; the token may not read the repository's Actions".to_owned()
}
ListingProblem::Refused { status } => format!(
"GitHub answers {status}; the token cannot see the repository, or it is gone"
),
ListingProblem::Failed { status } => format!("GitHub answers {status}"),
ListingProblem::Unreachable => "GitHub does not answer".to_owned(),
ListingProblem::Unexpected => "GitHub's answer is not what runnerd reads".to_owned(),
ListingProblem::Unknown => "for a reason this client does not know".to_owned(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PoolStatus {
pub profile: String,
pub labels: Vec<String>,
pub queued_jobs: usize,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct QueuedJob {
pub id: u64,
pub repository: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub profile: Option<String>,
pub run_id: u64,
pub run_attempt: u32,
pub workflow: Option<String>,
pub name: String,
pub branch: Option<String>,
pub url: Option<String>,
pub queued_at: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub waiting: Option<Waiting>,
}
fn starting_for(job: &QueuedJob, status: &Status) -> Option<String> {
status
.profiles
.iter()
.filter(|profile| job.profile.as_ref().is_none_or(|own| *own == profile.name))
.find_map(|profile| {
profile
.slots
.iter()
.find(|slot| {
slot.runner
.as_ref()
.is_some_and(|runner| runner.repository == job.repository && !runner.busy)
})
.map(|slot| format!("{}\u{a0}{}", profile.name, slot.slot))
})
}
impl QueuedJob {
pub fn place(&self, status: &Status) -> String {
let pools = status
.repositories
.iter()
.find(|repository| repository.name == self.repository)
.map_or(0, |repository| repository.pools.len());
match self.profile.as_deref().filter(|_| pools > 1) {
Some(profile) => format!("{}\u{a0}· {profile}", self.repository),
None => self.repository.clone(),
}
}
}
impl RepositoryStatus {
pub fn first_profile(&self) -> &str {
self.pools.first().map_or("", |pool| pool.profile.as_str())
}
pub fn profiles(&self) -> String {
self.pools
.iter()
.map(|pool| pool.profile.as_str())
.collect::<Vec<_>>()
.join(" + ")
}
pub fn pool_for(&self, labels: &[String]) -> Option<String> {
self.pools
.iter()
.find(|pool| crate::config::labels_match(labels, &pool.labels))
.map(|pool| pool.profile.clone())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum HoldCause {
NoJob,
IdleExits,
Register,
Start,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", tag = "kind")]
pub enum Waiting {
Paused,
Backoff {
until: u64,
cause: HoldCause,
},
RunnerStarting,
Reseeding {
profile: String,
},
PullingImage {
profile: String,
},
NoSlot {
profile: String,
},
Memory {
needs: u64,
free: u64,
},
HostMemory {
needs: u64,
free: u64,
},
Cpu {
needs: u64,
free: u64,
},
BehindCpu {
job: u64,
},
BehindMemory {
job: u64,
},
BehindStart {
job: u64,
},
NoPool {
labels: Vec<String>,
},
Torn {
volumes: Vec<String>,
},
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WaitKind {
Act,
Soon,
Full,
Other,
}
impl Waiting {
pub fn cannot_start(&self) -> bool {
matches!(self, Waiting::Paused | Waiting::NoPool { .. })
}
pub fn kind(&self) -> WaitKind {
match self {
Waiting::Paused | Waiting::Backoff { .. } | Waiting::NoPool { .. } => WaitKind::Act,
Waiting::Torn { volumes } if !volumes.is_empty() => WaitKind::Act,
Waiting::Unknown => WaitKind::Other,
Waiting::Torn { .. }
| Waiting::RunnerStarting
| Waiting::Reseeding { .. }
| Waiting::PullingImage { .. }
| Waiting::BehindStart { .. } => WaitKind::Soon,
Waiting::NoSlot { .. }
| Waiting::Memory { .. }
| Waiting::HostMemory { .. }
| Waiting::Cpu { .. }
| Waiting::BehindCpu { .. }
| Waiting::BehindMemory { .. } => WaitKind::Full,
}
}
pub fn reason(&self, job: &QueuedJob, status: &Status, now: u64) -> String {
let size = |bytes: u64| crate::config::ByteSize(bytes).to_string();
let older_name = |id: u64| {
status
.queued
.iter()
.find(|candidate| candidate.id == id)
.map_or_else(|| "an older job".to_owned(), |older| older.name.clone())
};
match self {
Waiting::Paused => format!("{} is paused", job.repository),
Waiting::Unknown => "Waits for a reason this client does not know yet".to_owned(),
Waiting::NoPool { labels } if labels.is_empty() => {
"It asks for no labels, so no profile serves it".to_owned()
}
Waiting::NoPool { labels } => format!(
"No profile serves the {} {}",
if labels.len() == 1 { "label" } else { "labels" },
labels.join(", ")
),
Waiting::Backoff { until, cause } => format!(
"{}; retrying in {}",
match cause {
HoldCause::NoJob => "Runners failed to take a job",
HoldCause::IdleExits => "Runners ended without a job after waiting for one",
HoldCause::Register => "Runners cannot register with GitHub",
HoldCause::Start => "Runners cannot start",
},
duration(until.saturating_sub(now))
),
Waiting::RunnerStarting => match starting_for(job, status) {
Some(slot) => format!("A runner is starting for it in {slot}"),
None => "A runner is starting for it".to_owned(),
},
Waiting::Reseeding { profile } => format!("{profile} is rebuilding its snapshot"),
Waiting::Torn { volumes } if volumes.is_empty() => {
"Emptying the caches a host crash may have torn".to_owned()
}
Waiting::Torn { volumes } => format!(
"A host crash may have torn caches a container holds; once nothing mounts them: docker volume rm {}",
volumes.join(" ")
),
Waiting::PullingImage { profile } => format!("Pulling {profile}'s image"),
Waiting::NoSlot { profile } => {
let slots = status
.profiles
.iter()
.find(|candidate| &candidate.name == profile)
.map_or(0, |profile| profile.slots.len());
if slots == 1 {
format!("The {profile} slot is busy")
} else {
format!("All {slots} {profile} slots are busy")
}
}
Waiting::Memory { .. } if status.budget.held => {
"The slice is past 90% of its MemoryMax, so nothing starts".to_owned()
}
Waiting::Memory { needs, free } => format!(
"Needs {} of memory; {} of the budget is free",
size(*needs),
size(*free)
),
Waiting::HostMemory { needs, free } => host_reason(
*needs,
*free,
status.budget.host.as_ref(),
status.budget.memory_in_use,
),
Waiting::Cpu { needs, free } => {
format!(
"Needs {}; {} are free",
cpus(*needs),
admission::free_cores(*free)
)
}
Waiting::BehindCpu { job: older } => {
format!("Behind {}, which waits for CPU", older_name(*older))
}
Waiting::BehindMemory { job: older } => {
format!("Behind {}, which waits for memory", older_name(*older))
}
Waiting::BehindStart { job: older } => {
format!(
"Next after {}, whose runner starts first",
older_name(*older)
)
}
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Dashboard {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub open: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct PairingQuery {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub origin: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Pairings {
pub links: Vec<Pairing>,
}
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Pairing {
pub origin: String,
pub url: String,
pub lifetime: u64,
}
impl std::fmt::Debug for Pairing {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter
.debug_struct("Pairing")
.field("origin", &self.origin)
.field("lifetime", &self.lifetime)
.finish_non_exhaustive()
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct ShutdownRequest {
#[serde(default)]
pub force: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct ShutdownAnswer {
pub stopping: Stopping,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Stopping {
WaitsForJobs,
LeavesJobs,
KillsJobs,
#[serde(other)]
Unknown,
}
impl Stopping {
pub fn line(self) -> &'static str {
match self {
Stopping::WaitsForJobs => "shutting down: waits for running jobs",
Stopping::LeavesJobs => "shutting down: leaves running jobs to the next start",
Stopping::KillsJobs => "shutting down: kills running jobs",
Stopping::Unknown => "shutting down",
}
}
}
impl Status {
pub fn stopping_line(&self) -> Option<&'static str> {
match (self.stopping, self.shutting_down) {
(Some(stopping), _) => Some(stopping.line()),
(None, true) => Some("shutting down"),
(None, false) => None,
}
}
pub fn github_line(&self) -> Option<&'static str> {
self.github_limited_until
.map(|_| "GitHub's rate limit is used up: no runner starts until it resets")
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ErrorResponse {
pub message: String,
}