node_flow/flows/parallel_flow/
mod.rs

1mod builder;
2pub use builder::*;
3mod flow;
4pub use flow::*;
5
6use crate::flows::NodeResult;
7mod chain_run;
8
9/// The `Joiner` handles the output of all nodes from [`ParallelFlow`].
10///
11/// `Joiner`s job is to handle the output of all nodes from [`ParallelFlow`]
12/// and decide how to handle it.
13/// At the end it should return an output that can be directly returned by [`ParallelFlow`].
14///
15/// See also [`ParallelFlow`].
16pub trait Joiner<'a, Input, Output, Error, Context>: Send + Sync {
17    /// Handles the output of all nodes from [`ParallelFlow`].
18    fn join(
19        &self,
20        input: Input,
21        context: &'a mut Context,
22    ) -> impl Future<Output = NodeResult<Output, Error>> + Send;
23}
24
25impl<'a, Input, Output, Error, Context, T, F> Joiner<'a, Input, Output, Error, Context> for T
26where
27    Input: Send,
28    F: Future<Output = NodeResult<Output, Error>> + Send + 'a,
29    T: Fn(Input, &'a mut Context) -> F + Send + Sync,
30    Context: 'a,
31{
32    fn join(
33        &self,
34        input: Input,
35        context: &'a mut Context,
36    ) -> impl Future<Output = NodeResult<Output, Error>> {
37        (self)(input, context)
38    }
39}