# rune-chain-parallel
> ParallelChain for rune-chain: fan-out to multiple chains concurrently and merge outputs.
[](https://crates.io/crates/rune-chain-parallel)
[](https://docs.rs/rune-chain-parallel)
[](LICENSE)
All registered steps execute simultaneously using `tokio::spawn`. Their
text outputs are merged into the shared variable map keyed by each
step's `output_key`, making them available to downstream chains. Token
usage across all branches is summed.
## Usage
```rust,no_run
use rune_chain_parallel::ParallelChain;
use rune_chain_core::{Chain, ChainError, GenerateResult, PromptArgs, prompt_args};
use async_trait::async_trait;
struct UpperCase;
#[async_trait]
impl Chain for UpperCase {
async fn call(&self, input: PromptArgs) -> Result<GenerateResult, ChainError> {
let text = input.get("input").and_then(|v| v.as_str()).unwrap_or("").to_uppercase();
Ok(GenerateResult::from_text(text))
}
}
# #[tokio::main]
# async fn main() {
let chain = ParallelChain::new().branch(UpperCase, "upper");
let result = chain.call(prompt_args! { "input" => "hi" }).await.unwrap();
# let _ = result;
# }
```
## License
MIT