From b778211de8250b3451c64358a452c98dbb0334a1 Mon Sep 17 00:00:00 2001 From: Vikrant Chaudhary Date: Thu, 3 Jul 2025 17:59:34 +0200 Subject: [PATCH] feat: [Experimental] Send nanoseconds timestamp for runlog outputs. --- pb/A2o.proto | 3 ++- src/generated/pb/a2o.rs | 3 +++ src/o2a_messages/runlog_run.rs | 3 ++- src/utils.rs | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pb/A2o.proto b/pb/A2o.proto index 919d974..8e8eaf2 100644 --- a/pb/A2o.proto +++ b/pb/A2o.proto @@ -91,9 +91,10 @@ enum OutputStreamType { message RunlogOutputFragment { uint64 runlog_id = 1; - uint64 output_at_ts = 2; + uint64 output_at_ts = 2 [deprecated = true]; OutputStreamType stream_type = 3; bytes output_fragment = 4; + uint64 output_at_nano_ts = 5; } message A2oMessage { diff --git a/src/generated/pb/a2o.rs b/src/generated/pb/a2o.rs index 5cbfc20..d5457a3 100644 --- a/src/generated/pb/a2o.rs +++ b/src/generated/pb/a2o.rs @@ -92,12 +92,15 @@ pub struct RunlogFinished { pub struct RunlogOutputFragment { #[prost(uint64, tag = "1")] pub runlog_id: u64, + #[deprecated] #[prost(uint64, tag = "2")] pub output_at_ts: u64, #[prost(enumeration = "OutputStreamType", tag = "3")] pub stream_type: i32, #[prost(bytes = "vec", tag = "4")] pub output_fragment: ::prost::alloc::vec::Vec, + #[prost(uint64, tag = "5")] + pub output_at_nano_ts: u64, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct A2oMessage { diff --git a/src/o2a_messages/runlog_run.rs b/src/o2a_messages/runlog_run.rs index c941c18..3482f0c 100644 --- a/src/o2a_messages/runlog_run.rs +++ b/src/o2a_messages/runlog_run.rs @@ -6,7 +6,7 @@ use crate::generated::pb::a2o::{ }; use crate::generated::pb::o2a::RunlogRun; use crate::message_queue::MessageQueue; -use crate::utils::current_timestamp_secs; +use crate::utils::{current_timestamp_nanos, current_timestamp_secs}; use std::fs; use std::path::PathBuf; use std::process::Stdio; @@ -115,6 +115,7 @@ where MessageQueue::push(A2oPayload::RunlogOutputFragment(RunlogOutputFragment { runlog_id, output_at_ts: current_timestamp_secs()?, + output_at_nano_ts: current_timestamp_nanos()?, stream_type: stream_type as i32, output_fragment: buffer[..n].to_vec(), })) diff --git a/src/utils.rs b/src/utils.rs index 4e641ea..b40619d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -7,3 +7,7 @@ pub fn current_timestamp() -> anyhow::Result { pub fn current_timestamp_secs() -> anyhow::Result { current_timestamp().map(|d| d.as_secs()) } + +pub fn current_timestamp_nanos() -> anyhow::Result { + current_timestamp().map(|d| d.as_nanos() as u64) +}