Module parallelize

Module parallelize 

Source
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§

ParallelizeLayer
Middleware for emitting events
ParallelizeService
Service for emitting events

Traits§

ParallelizeExt
Worker extension for parallel execution