pub enum ChunkedBatchProcessError<E> {
CountShortfall {
expected: usize,
actual: usize,
result: BatchProcessResult,
},
CountExceeded {
expected: usize,
observed_at_least: usize,
result: BatchProcessResult,
},
ChunkFailed {
chunk_index: usize,
start_index: usize,
chunk_len: usize,
source: E,
result: BatchProcessResult,
},
InvalidChunkResult {
chunk_index: usize,
start_index: usize,
chunk_len: usize,
item_count: usize,
completed_count: usize,
result: BatchProcessResult,
},
}Expand description
Error returned by crate::ChunkedBatchProcessor.
Count-mismatch variants carry the aggregate result accumulated before the
mismatch was detected. ChunkFailed carries the delegate error plus the
aggregate result collected before the failing chunk. InvalidChunkResult
means the delegate returned Ok, but the returned item_count or
completed_count did not match the submitted chunk length.
use std::time::Duration;
use qubit_batch::{
BatchProcessResult,
ChunkedBatchProcessError,
};
let result = BatchProcessResult::builder(4)
.completed_count(2)
.processed_count(2)
.chunk_count(1)
.elapsed(Duration::ZERO)
.build()
.expect("process result counters should be valid");
let error: ChunkedBatchProcessError<&'static str> =
ChunkedBatchProcessError::ChunkFailed {
chunk_index: 1,
start_index: 2,
chunk_len: 2,
source: "insert failed",
result,
};
assert_eq!(error.result().processed_count(), 2);§Type Parameters
E- Error type returned by the delegate processor.
Variants§
CountShortfall
The input source ended before the declared item count was reached.
Fields
result: BatchProcessResultResult accumulated before the shortfall was reported.
CountExceeded
The input source yielded more items than the declared item count.
Fields
result: BatchProcessResultResult accumulated before the excess item was observed.
ChunkFailed
The delegate processor failed while processing one chunk.
Fields
source: EError returned by the delegate processor.
result: BatchProcessResultResult accumulated before this chunk failed.
InvalidChunkResult
The delegate returned Ok with counters that do not describe the
submitted chunk.
A successful chunk delegate call must report both item_count and
completed_count equal to chunk_len. A lower processed_count is
allowed, but partial chunk completion should be represented by delegate
failure instead of an inconsistent success result.
Fields
result: BatchProcessResultResult accumulated before this invalid chunk result was reported.
Implementations§
Source§impl<E> ChunkedBatchProcessError<E>
impl<E> ChunkedBatchProcessError<E>
Sourcepub const fn result(&self) -> &BatchProcessResult
pub const fn result(&self) -> &BatchProcessResult
Returns the partial result attached to this error.
§Returns
A shared reference to the partial batch process result.
Sourcepub fn into_result(self) -> BatchProcessResult
pub fn into_result(self) -> BatchProcessResult
Trait Implementations§
Source§impl<E: Clone> Clone for ChunkedBatchProcessError<E>
impl<E: Clone> Clone for ChunkedBatchProcessError<E>
Source§fn clone(&self) -> ChunkedBatchProcessError<E>
fn clone(&self) -> ChunkedBatchProcessError<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E: Debug> Debug for ChunkedBatchProcessError<E>
impl<E: Debug> Debug for ChunkedBatchProcessError<E>
Source§impl<E> Display for ChunkedBatchProcessError<E>
impl<E> Display for ChunkedBatchProcessError<E>
Source§impl<E> Error for ChunkedBatchProcessError<E>
impl<E> Error for ChunkedBatchProcessError<E>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E: PartialEq> PartialEq for ChunkedBatchProcessError<E>
impl<E: PartialEq> PartialEq for ChunkedBatchProcessError<E>
Source§fn eq(&self, other: &ChunkedBatchProcessError<E>) -> bool
fn eq(&self, other: &ChunkedBatchProcessError<E>) -> bool
self and other values to be equal, and is used by ==.