Available on crate features
worker-batch or worker-pool or worker only.Expand description
Adaptive worker pool and batch processing framework.
Two layers:
-
Generic:
AdaptiveWorkerPoolprovides CPU-saturating parallelism via rayon (CPU-bound) + tokio (async I/O), with reactive pressure-based scaling. Useful for any workload – not DFE-specific. -
Opinionated:
BatchProcessortrait +BatchPipelineprovide a structured parallel-then-sequential pipeline for DFE apps. Apps implementBatchProcessorfor their domain; the pipeline handles stats, scaling, and batch orchestration.PipelineStatsprovides common atomic counters.
§Quick Start
ⓘ
use hyperi_rustlib::worker::{AdaptiveWorkerPool, WorkerPoolConfig};
let pool = AdaptiveWorkerPool::from_cascade("worker_pool")?;
pool.register_metrics(&metrics_manager);
pool.start_scaling_loop(shutdown_token.clone());
// CPU-bound parallel transform (rayon)
let results = pool.process_batch(&messages, |msg| {
parse_and_transform(msg)
});
// Async parallel enrichment (tokio)
let enriched = pool.fan_out_async(&items, |item| async move {
enrich(item).await
}).await;Re-exports§
pub use engine::BatchEngine;worker-batchpub use engine::BatchProcessingConfig;worker-batchpub use engine::FieldInterner;worker-batchpub use engine::MessageMetadata;worker-batchpub use engine::ParsedMessage;worker-batchpub use engine::PreRouteFilterConfig;worker-batchpub use engine::CommitMode;transportandworker-batchpub use engine::EngineError;transportandworker-batchpub use engine::FilterDlqPolicy;transportandworker-batchpub use engine::ParsedBatch;transportandworker-batch
Modules§
Structs§
- Accumulator
Config - Accumulator configuration.
- Accumulator
Full - Error when the accumulator channel is full (backpressure).
- Adaptive
Worker Pool - Adaptive worker pool with hybrid rayon (CPU) + tokio (async I/O) execution.
- Batch
Accumulator - Push handle – cloneable, used by producers to send items into the accumulator.
- Batch
Drainer - Drain handle – used by a single consumer to receive batches.
- Batch
Pipeline - Orchestrates parallel batch processing via
AdaptiveWorkerPool. - FanOut
Policy - Policy for
AdaptiveWorkerPool::fan_out_async_with_policy. - Pipeline
Stats - Common DFE pipeline statistics with atomic counters.
- Pipeline
Stats Snapshot - Immutable snapshot of pipeline stats.
- Scaling
Decision - Result of the watermark scaling algorithm.
- Scaling
Input - Inputs to the watermark scaling algorithm.
- Worker
Pool Config - Configuration for the adaptive worker pool.
Enums§
- FanOut
Result - Per-item outcome from
AdaptiveWorkerPool::fan_out_async_with_policy.
Traits§
- Batch
Processor - Trait for parallel-safe message processing.
Functions§
- records_
into_ work_ batch - Drain accumulated
Records into aWorkBatchfor push-ingest sources.