#batch-processing #batch-file #input-file #validation #file-processing #file-validation #batch-mode #logging #output-file

batch-mode-batch-triple

Manages batch file triples (input, output, error, metadata) in batch processing systems, including file validation, error handling, and file movement

4 releases

Uses new Rust 2024

0.2.4 Nov 30, 2025
0.2.2 Jul 13, 2025
0.2.1 Mar 31, 2025
0.2.0 Feb 27, 2025

#9 in #file-validation

Download history 320/week @ 2025-12-05 236/week @ 2025-12-12 232/week @ 2025-12-19 199/week @ 2025-12-26 254/week @ 2026-01-02 81/week @ 2026-01-09 323/week @ 2026-01-16 249/week @ 2026-01-23 258/week @ 2026-01-30 265/week @ 2026-02-06 143/week @ 2026-02-13 241/week @ 2026-02-20 211/week @ 2026-02-27 153/week @ 2026-03-06 240/week @ 2026-03-13 310/week @ 2026-03-20

914 downloads per month
Used in 115 crates (9 directly)

MIT license

390KB
6.5K SLoC

batch-mode-batch-triple

The batch-mode-batch-triple crate provides the BatchFileTriple structure and associated methods for managing and processing batch files within a batch processing system. It integrates with the rest of the batch-mode ecosystem to handle batch file states, perform error handling, validate file consistency, and move batch files to a "done" directory upon completion.

Key Features

  • BatchFileTriple Management: Represents a set of batch files (input, output, error, and metadata) associated with a specific batch index.
  • File Validation: Ensures that batch files, such as input, output, and error files, match in terms of request IDs, and validates their integrity.
  • Error Handling: Provides methods for logging and retrying failed batch file processing requests.
  • File Movement: Supports moving batch files to a "done" directory once processed to ensure proper workflow management.
  • State Management: Determines the current state of batch files (input-only, input-output, input-error, or input-output-error).

Usage

Creating a BatchFileTriple

You can create a new BatchFileTriple with a set of requests and specify a workspace for file management.

use batch_mode_batch_triple::BatchFileTriple;
use batch_mode_batch_workspace_interface::BatchWorkspaceInterface;
use std::sync::Arc;

let workspace: Arc<dyn BatchWorkspaceInterface> = // obtain workspace
let batch_triple = BatchFileTriple::new_with_requests(&requests, workspace)?;

File Validation

Use the ensure_input_matches_output_and_error method to validate that input, output, and error files have matching request IDs.

batch_triple.ensure_input_matches_output_and_error().await?;

Error Handling

Log errors in the batch processing workflow with the log_errors method.

batch_triple.log_errors(&error_data).await?;

Retry failed requests using the retry_failed_requests method:

batch_triple.retry_failed_requests(&error_data).await?;

Moving Files

After processing a batch, you can move the batch files to a "done" directory.

batch_triple.move_input_and_output_to_done().await?;

Ensuring File Consistency

Ensure that the input file matches the output file:

batch_triple.ensure_input_matches_output().await?;

Ensure that the input file matches the error file:

batch_triple.ensure_input_matches_error().await?;

Error Handling

The crate uses custom error types for managing batch file processing errors:

  • BatchErrorProcessingError: Errors encountered while processing batch error files.
  • BatchValidationError: Errors related to validation, such as mismatched request IDs.
  • FileMoveError: Errors encountered when moving files to the "done" directory.

License

This crate is licensed under the MIT License. See LICENSE for details.

Dependencies

~28–51MB
~712K SLoC