Skip to main content

runnerd_core/api/
labels.rs

1//! The names every client gives the same thing: its views and the columns of a table of jobs. A client lays a name
2//! out, upper-cases it or fits it; it does not spell its own.
3
4/// A page of the web dashboard, a view of `runnerctl tui`, in the order every client lists them: the views that
5/// look at the present, then the history and what it advises, then the host and its config.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum View {
8    /// Budget, slots, the queue and the latest jobs.
9    Overview,
10    /// Finished and running jobs, filtered.
11    History,
12    /// The records of failed jobs.
13    Records,
14    /// What each profile's jobs use and what to set.
15    Sizing,
16    /// What the history says: jobs that got slower, are flaky or near their cap.
17    Insights,
18    /// The cache volumes and the build cache.
19    Caches,
20    /// The daemon's config.
21    Config,
22}
23
24impl View {
25    /// Every view, in order.
26    pub const ALL: [View; 7] = [
27        View::Overview,
28        View::History,
29        View::Records,
30        View::Sizing,
31        View::Insights,
32        View::Caches,
33        View::Config,
34    ];
35
36    /// What clients call it.
37    pub fn title(self) -> &'static str {
38        match self {
39            View::Overview => "Overview",
40            View::History => "History",
41            View::Records => "Records",
42            View::Sizing => "Sizing",
43            View::Insights => "Insights",
44            View::Caches => "Caches",
45            View::Config => "Config",
46        }
47    }
48}
49
50/// A column of a table of jobs or of records, as the history, `runnerctl jobs` and the records name it.
51#[derive(Debug, Clone, Copy, PartialEq, Eq)]
52pub enum Column {
53    /// GitHub's number for the job.
54    Id,
55    /// How the job ended, or that it is running.
56    Outcome,
57    /// Its workflow and name.
58    Job,
59    /// Its repository.
60    Repository,
61    /// Its branch.
62    Branch,
63    /// When GitHub queued it.
64    Queued,
65    /// How long it waited for a runner.
66    Waited,
67    /// How long it ran.
68    Ran,
69    /// The highest memory its sampled use reached.
70    MemoryPeak,
71    /// Its average CPU, in cores.
72    Cpu,
73    /// When a record of the failed job was made.
74    Made,
75    /// How much disk a record takes.
76    Size,
77}
78
79impl Column {
80    /// What clients call it.
81    pub fn title(self) -> &'static str {
82        match self {
83            Column::Id => "ID",
84            Column::Outcome => "Outcome",
85            Column::Job => "Job",
86            Column::Repository => "Repository",
87            Column::Branch => "Branch",
88            Column::Queued => "Queued",
89            Column::Waited => "Waited",
90            Column::Ran => "Ran",
91            Column::MemoryPeak => "Memory peak",
92            Column::Cpu => "CPU",
93            Column::Made => "Made",
94            Column::Size => "Size",
95        }
96    }
97}