Expand description
Worker extension for parallel execution and spawning child tasks.
This module provides functionality to parallelize task execution within a worker
and spawn child tasks. It includes the ParallelizeLayer middleware for parallel execution
and the ParallelizeService service.
§Example
#[tokio::main]
async fn main() {
async fn task(task: u32) {
println!("Processing task: {task}");
}
let in_memory = MemoryStorage::new();
let worker = WorkerBuilder::new("rango-tango")
.backend(in_memory)
.parallelize(tokio::spawn)
.on_event(|ctx, ev| {
println!("CTX {:?}, On Event = {:?}", ctx.name(), ev);
})
.build(task);
worker.run().await.unwrap();
}Structs§
- Parallelize
Layer - Middleware for emitting events
- Parallelize
Service - Service for emitting events
Traits§
- Parallelize
Ext - Worker extension for parallel execution