pub struct BatchEngine { /* private fields */ }Expand description
Wraps Engine for concurrent multi-document processing with backpressure.
The underlying Engine is shared via Arc; cloning BatchEngine is cheap.
Implementations§
Source§impl BatchEngine
impl BatchEngine
pub fn new(engine: Engine, options: BatchOptions) -> Self
Sourcepub fn lint_many(
&self,
docs: impl IntoIterator<Item = (String, Vec<u8>)>,
) -> impl Stream<Item = (String, Result<LintResult, BatchError>)>
pub fn lint_many( &self, docs: impl IntoIterator<Item = (String, Vec<u8>)>, ) -> impl Stream<Item = (String, Result<LintResult, BatchError>)>
Lint many documents concurrently. Yields (id, Result) in
completion order; an Err indicates the per-document task
panicked, was cancelled, or could not start because shutdown
is in progress (the ConcurrencyController semaphore was
closed) — it does not abort the batch.
Honors BatchOptions::per_doc_deadline from construction time
(spec 005 §R2). A deadline-truncated lint surfaces as
Ok(LintResult { truncated: true, .. }) — the partial
diagnostics are useful, so they flow through the success
channel rather than Err.
Sourcepub fn lint_many_with_options(
&self,
docs: impl IntoIterator<Item = (String, Vec<u8>)>,
opts: &BatchOptions,
) -> impl Stream<Item = (String, Result<LintResult, BatchError>)>
pub fn lint_many_with_options( &self, docs: impl IntoIterator<Item = (String, Vec<u8>)>, opts: &BatchOptions, ) -> impl Stream<Item = (String, Result<LintResult, BatchError>)>
Same as lint_many but reads per_doc_deadline from the
supplied BatchOptions instead of the construction-time
default. Other fields on opts are reserved for future
per-call overrides; in MVP only per_doc_deadline is honored.
Sourcepub fn fix_many(
&self,
docs: impl IntoIterator<Item = (String, Vec<u8>)>,
) -> impl Stream<Item = (String, Result<FixResult, BatchError>)>
pub fn fix_many( &self, docs: impl IntoIterator<Item = (String, Vec<u8>)>, ) -> impl Stream<Item = (String, Result<FixResult, BatchError>)>
Fix many documents concurrently. Yields (id, Result) in
completion order; an Err indicates the per-document task
panicked, was cancelled, hit the per-document deadline, or the
runtime is shutting down — it does not abort the batch.
Honors BatchOptions::per_doc_deadline from construction
time. A deadline trip on the fix path returns
Err(BatchError::DocumentDeadlineExceeded { partial_lint })
per Constitution V Principle V — no partial FixResult is
ever produced. Match on is_deadline_exceeded() to
distinguish from worker bugs (is_panic()) or shutdown
(is_shutdown()).
Sourcepub fn fix_many_with_options(
&self,
docs: impl IntoIterator<Item = (String, Vec<u8>)>,
opts: &BatchOptions,
) -> impl Stream<Item = (String, Result<FixResult, BatchError>)>
pub fn fix_many_with_options( &self, docs: impl IntoIterator<Item = (String, Vec<u8>)>, opts: &BatchOptions, ) -> impl Stream<Item = (String, Result<FixResult, BatchError>)>
Same as fix_many but reads per_doc_deadline from the
supplied BatchOptions instead of the construction-time
default. Other fields on opts are reserved for future
per-call overrides; in MVP only per_doc_deadline is honored.