lay groundwork for log line parsing

This commit is contained in:
Stuart Axelbrooke 2025-10-16 19:27:25 -07:00
parent 1f4138ecc0
commit cb580f83eb
5 changed files with 32 additions and 7 deletions

21
databuild/data_deps.rs Normal file
View file

@ -0,0 +1,21 @@
use crate::JobRunMissingDeps;
pub struct LogLine(String);
const DATABUILD_JSON: &str = "DATABUILD_JSON:";
const DATABUILD_JSON_LEN: usize = DATABUILD_JSON.len();
impl From<LogLine> for Option<JobRunMissingDeps> {
fn from(value: LogLine) -> Self {
line_matches(&value.0).and_then(json_to_missing_deps)
}
}
fn line_matches(line: &str) -> Option<&str> {
line.trim().strip_prefix(DATABUILD_JSON)
}
fn json_to_missing_deps(line: &str) -> Option<JobRunMissingDeps> {
todo!()
}

View file

@ -86,6 +86,9 @@ message JobRunMissingDepsEventV1 {
string job_run_id = 1;
repeated MissingDeps missing_deps = 2;
}
message JobRunMissingDeps {
repeated MissingDeps missing_deps = 2;
}
message MissingDeps {
// The list of partition refs that are prevented from building by these missing deps (can be just 1)
repeated PartitionRef impacted = 1;

View file

@ -1,6 +1,6 @@
use crate::data_build_event::Event;
use crate::util::current_timestamp;
use crate::{event_source, EventSource, JobRunStatus, JobRunStatusCode, ManuallyTriggeredEvent, PartitionRef, PartitionStatus, PartitionStatusCode, WantCancelEventV1, WantCreateEventV1, WantDetail, WantStatus, WantStatusCode};
use crate::data_build_event::Event;
impl From<&WantCreateEventV1> for WantDetail {
fn from(e: &WantCreateEventV1) -> Self {

View file

@ -1,9 +1,9 @@
use std::collections::HashMap;
use std::marker::PhantomData;
use crate::data_build_event::Event;
use crate::{JobRunHeartbeatEventV1, JobRunStatus, JobRunStatusCode, JobRunSuccessEventV1, JobRunFailureEventV1, JobRunCancelEventV1, EventSource};
use crate::{EventSource, JobRunCancelEventV1, JobRunFailureEventV1, JobRunStatus, JobRunSuccessEventV1};
use std::collections::HashMap;
use std::error::Error;
use std::io::{BufRead, BufReader};
use std::marker::PhantomData;
use std::process::{Child, Command, Stdio};
use uuid::Uuid;
@ -314,10 +314,10 @@ pub struct JobRunPollResult {
}
mod tests {
use std::collections::HashMap;
use crate::data_build_event::Event;
use crate::job_run::{JobRunBackend, JobRunVisitResult, NotStartedJobRun, SubProcessBackend};
use crate::{ManuallyTriggeredEvent};
use crate::job_run::{JobRunBackend, JobRunVisitResult, SubProcessBackend};
use crate::ManuallyTriggeredEvent;
use std::collections::HashMap;
fn test_helper_path() -> String {
std::env::var("TEST_SRCDIR")

View file

@ -6,6 +6,7 @@ mod util;
mod build_state;
mod event_transforms;
mod event_defaults;
mod data_deps;
// Include generated protobuf code
include!("databuild.rs");