Skip to main content

opal/pipeline/
planner.rs

1use crate::model::EnvironmentSpec;
2use anyhow::Result;
3use std::path::PathBuf;
4use std::time::Instant;
5
6#[derive(Debug, Clone)]
7pub struct JobSummary {
8    pub name: String,
9    pub stage_name: String,
10    pub duration: f32,
11    pub status: JobStatus,
12    pub log_path: Option<PathBuf>,
13    pub log_hash: String,
14    pub allow_failure: bool,
15    pub environment: Option<EnvironmentSpec>,
16}
17
18#[derive(Debug, Clone)]
19pub enum JobStatus {
20    Success,
21    Failed(String),
22    Skipped(String),
23}
24
25#[derive(Debug, Clone)]
26pub struct JobRunInfo {
27    pub container_name: String,
28}
29
30#[derive(Debug)]
31pub struct JobEvent {
32    pub name: String,
33    pub stage_name: String,
34    pub duration: f32,
35    pub log_path: Option<PathBuf>,
36    pub log_hash: String,
37    pub result: Result<()>,
38    pub failure_kind: Option<JobFailureKind>,
39    pub exit_code: Option<i32>,
40    pub cancelled: bool,
41}
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq)]
44pub enum JobFailureKind {
45    UnknownFailure,
46    ScriptFailure,
47    ApiFailure,
48    JobExecutionTimeout,
49    RunnerUnsupported,
50    StaleSchedule,
51    ArchivedFailure,
52    UnmetPrerequisites,
53    SchedulerFailure,
54    DataIntegrityFailure,
55    RunnerSystemFailure,
56    StuckOrTimeoutFailure,
57}
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq)]
60pub enum HaltKind {
61    None,
62    JobFailure,
63    Deadlock,
64    ChannelClosed,
65    Aborted,
66}
67
68#[derive(Debug, Clone)]
69pub struct StageState {
70    pub total: usize,
71    pub completed: usize,
72    pub header_printed: bool,
73    pub started_at: Option<Instant>,
74}
75
76impl StageState {
77    pub fn new(total: usize) -> Self {
78        Self {
79            total,
80            completed: 0,
81            header_printed: false,
82            started_at: None,
83        }
84    }
85}