pub struct BatchStore { /* private fields */ }Expand description
Disk-backed store for batch jobs.
All methods are synchronous — they are intended to be called from a
tokio::task::spawn_blocking context or from the background batch worker.
Implementations§
Source§impl BatchStore
impl BatchStore
Sourcepub fn new(dir: PathBuf) -> Result<Self>
pub fn new(dir: PathBuf) -> Result<Self>
Open (or create) the spool directory.
Returns an error if the directory cannot be created.
Sourcepub fn create_job(
&self,
job_id: &str,
input_jsonl: &str,
endpoint: &str,
total_lines: u32,
) -> Result<BatchJobMeta>
pub fn create_job( &self, job_id: &str, input_jsonl: &str, endpoint: &str, total_lines: u32, ) -> Result<BatchJobMeta>
Create a new job on disk.
Writes input.jsonl with the supplied content and writes an initial
status.json atomically.
Returns an error if a job with the same ID already exists.
Sourcepub fn update_status(&self, job_id: &str, status: &BatchJobMeta) -> Result<()>
pub fn update_status(&self, job_id: &str, status: &BatchJobMeta) -> Result<()>
Overwrite status.json atomically.
Sourcepub fn read_status(&self, job_id: &str) -> Result<BatchJobMeta>
pub fn read_status(&self, job_id: &str) -> Result<BatchJobMeta>
Read status.json for a job.
Sourcepub fn append_output(&self, job_id: &str, line: &str) -> Result<()>
pub fn append_output(&self, job_id: &str, line: &str) -> Result<()>
Append a single JSONL line to output.jsonl.
The line must NOT contain a trailing newline — one will be added.
Sourcepub fn append_error(&self, job_id: &str, line: &str) -> Result<()>
pub fn append_error(&self, job_id: &str, line: &str) -> Result<()>
Append a single JSONL error record to errors.jsonl.
Sourcepub fn read_input_lines(&self, job_id: &str) -> Result<Vec<String>>
pub fn read_input_lines(&self, job_id: &str) -> Result<Vec<String>>
Read all lines from input.jsonl.
Sourcepub fn read_output_lines(&self, job_id: &str) -> Result<Vec<String>>
pub fn read_output_lines(&self, job_id: &str) -> Result<Vec<String>>
Read all output lines from output.jsonl.
Sourcepub fn in_progress_jobs(&self) -> Result<Vec<String>>
pub fn in_progress_jobs(&self) -> Result<Vec<String>>
Return job IDs whose status is InProgress or Pending.
Used at startup to re-enqueue jobs that survived a restart.
Auto Trait Implementations§
impl Freeze for BatchStore
impl RefUnwindSafe for BatchStore
impl Send for BatchStore
impl Sync for BatchStore
impl Unpin for BatchStore
impl UnsafeUnpin for BatchStore
impl UnwindSafe for BatchStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more