| Crates.io | batch-mode-process-response |
| lib.rs | batch-mode-process-response |
| version | 0.2.3 |
| created_at | 2025-02-27 06:14:05.965854+00 |
| updated_at | 2025-07-13 10:47:22.217992+00 |
| description | Handles batch responses, errors, and JSON repairs in a batch processing system. |
| homepage | |
| repository | https://github.com/klebs6/klebs-general |
| max_upload_size | |
| id | 1571374 |
| size | 156,423 |
The batch-mode-process-response crate is designed to manage the processing of batch responses within a larger batch-processing system. It provides functionality for handling successful responses, error data, file processing, and failed JSON repairs. This crate is an integral part of batch workflows that involve processing outputs, handling errors, and managing responses in an asynchronous and robust manner.
The crate offers the process_output_data function to process batch output responses, handling successful responses and saving the failed ones.
pub async fn process_output_data(
output_data: &BatchOutputData,
workspace: &dyn BatchWorkspaceInterface,
expected_content_type: &ExpectedContentType,
) -> Result<(), BatchOutputProcessingError>;
It processes successful responses, including handling different content types (e.g., JSON and plain text), with options for saving them to the disk.
pub async fn handle_successful_response(
success_body: &BatchSuccessResponseBody,
workspace: &dyn BatchWorkspaceInterface,
expected_content_type: &ExpectedContentType,
) -> Result<(), BatchSuccessResponseHandlingError>;
If JSON parsing fails, the crate allows logging the failed content into a specific directory.
pub async fn handle_failed_json_repair(
failed_id: &str,
message_content: &BatchMessageContent,
workspace: &dyn BatchWorkspaceInterface,
) -> Result<(), BatchSuccessResponseHandlingError>;
The crate also provides functionality for processing error files, including operations like logging errors and retrying failed requests.
pub async fn process_error_file(
triple: &BatchFileTriple,
operations: &[BatchErrorFileProcessingOperation],
) -> Result<(), BatchErrorProcessingError>;
To process the batch output data, use the process_output_data function:
process_output_data(&output_data, workspace, &expected_content_type).await?;
The handle_successful_response function is used to handle successful responses and the corresponding content type:
handle_successful_response(&success_body, workspace, &expected_content_type).await?;
If there's a failed JSON repair, use the handle_failed_json_repair function:
handle_failed_json_repair(&failed_id, &message_content, workspace).await?;
The crate includes error handling for:
This crate is licensed under the MIT License. See LICENSE for details.