Skip to main content

JobDir

Struct JobDir 

Source
pub struct JobDir {
    pub path: PathBuf,
    pub job_id: String,
}
Expand description

Handle to a specific job’s directory.

Fields§

§path: PathBuf§job_id: String

Implementations§

Source§

impl JobDir

Source

pub fn open(root: &Path, job_id: &str) -> Result<Self>

Open an existing job directory by ID or unambiguous prefix.

Resolution order:

  1. Exact match: if root/<job_id> exists, return it immediately (no scan).
  2. Prefix scan: scan root/ for directories whose name starts with job_id.
    • 0 matches → Err(JobNotFound)
    • 1 match → resolve to that job
    • 2+ matches → Err(AmbiguousJobId)
Source

pub fn create(root: &Path, job_id: &str, meta: &JobMeta) -> Result<Self>

Create a new job directory and write meta.json atomically.

Source

pub fn meta_path(&self) -> PathBuf

Source

pub fn state_path(&self) -> PathBuf

Source

pub fn stdout_path(&self) -> PathBuf

Source

pub fn stderr_path(&self) -> PathBuf

Source

pub fn full_log_path(&self) -> PathBuf

Source

pub fn completion_event_path(&self) -> PathBuf

Source

pub fn notification_events_path(&self) -> PathBuf

Source

pub fn write_completion_event_atomic( &self, record: &CompletionEventRecord, ) -> Result<()>

Write completion_event.json atomically.

Source

pub fn read_meta(&self) -> Result<JobMeta>

Source

pub fn read_state(&self) -> Result<JobState>

Source

pub fn write_meta_atomic(&self, meta: &JobMeta) -> Result<()>

Write meta.json atomically: write to a temp file then rename.

Source

pub fn write_state(&self, state: &JobState) -> Result<()>

Write state.json atomically: write to a temp file then rename.

Source

pub fn tail_log( &self, filename: &str, tail_lines: u64, max_bytes: u64, ) -> String

Read the last max_bytes of a log file, returning lossy UTF-8.

Source

pub fn tail_log_with_truncated( &self, filename: &str, tail_lines: u64, max_bytes: u64, ) -> (String, bool)

Read the last max_bytes of a log file, returning (content, truncated). truncated is true when the content was cut by bytes or lines constraints.

Source

pub fn read_tail_metrics( &self, filename: &str, tail_lines: u64, max_bytes: u64, ) -> TailMetrics

Read tail content and byte metrics for a single log file.

Returns a TailMetrics that bundles the tail text, truncation flag, observed file size, and included byte count. Both run’s snapshot generation and tail’s JSON generation use this helper so that the metric calculation is defined in exactly one place.

encoding is always "utf-8-lossy" (as required by the contract).

Source

pub fn init_state_created(&self) -> Result<JobState>

Write the initial JobState for a created (not-yet-started) job.

The state is created, no process has been spawned, and started_at is absent.

Source

pub fn init_state(&self, pid: u32, started_at: &str) -> Result<JobState>

Write the initial JobState (running, supervisor PID) to disk.

This is called by the run command immediately after the supervisor process is spawned, so pid is the supervisor’s PID. The child process PID and, on Windows, the Job Object name are not yet known at this point.

On Windows, the Job Object name is derived deterministically from the job_id as "AgentExec-{job_id}". This name is written immediately to state.json so that callers reading state after run returns can always find the Job Object identifier, without waiting for the supervisor to perform its first write_state call. The supervisor will confirm the same name (or update to failed) after it successfully assigns the child process to the named Job Object.

Trait Implementations§

Source§

impl Debug for JobDir

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,