Exemplo n.º 1
0
        public static GraphDsl.Builder <TMat> To <TIn, TOut1, TOut2, TMat>(this GraphDsl.ForwardOps <TOut1, TMat> ops, UniformFanInShape <TIn, TOut2> junction)
            where TIn : TOut1
        {
            var b     = ops.Builder;
            var inlet = GraphDsl.FindIn(b, junction, 0);

            b.AddEdge(ops.Out, inlet);
            return(b);
        }
Exemplo n.º 2
0
        private static Source <TOut, TMat> UnfoldFlowGraph <TOut, TState, TFlowOut, TMat>(GraphStage <FanOutShape <TFlowOut, TState, TOut> > fanOut2Stage, IGraph <FlowShape <TState, TFlowOut>, TMat> flow)
        {
            var graph = GraphDsl.Create(flow, (b, f) =>
            {
                var fo2 = b.Add(fanOut2Stage);
                b.From(fo2.Out0).Via(f).To(fo2.In);

                return(new SourceShape <TOut>(fo2.Out1));
            });

            return(Source.FromGraph(graph));
        }
Exemplo n.º 3
0
        public static IGraph <FlowShape <Tuple <TIn, TState>, Tuple <Result <TOut>, TState> >, TMat> Concat <TIn, TState, TOut, TMat>(long limit,
                                                                                                                                      IGraph <FlowShape <Tuple <TIn, TState>, Tuple <Result <TOut>, TState> >, TMat> flow, Func <TState, IEnumerable <Tuple <TIn, TState> > > retryWith)
        {
            return(GraphDsl.Create(flow, (b, origFlow) =>
            {
                var retry = b.Add(new RetryConcatCoordinator <TIn, TState, TOut>(limit, retryWith));

                b.From(retry.Outlet2).Via(origFlow).To(retry.Inlet2);

                return new FlowShape <Tuple <TIn, TState>, Tuple <Result <TOut>, TState> >(retry.Inlet1, retry.Outlet1);
            }));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Combines several sources with fun-in strategy like <see cref="Merge{TIn,TOut}"/> or <see cref="Concat{TIn,TOut}"/> and returns <see cref="Source{TOut,TMat}"/>.
        /// </summary>
        /// <typeparam name="T">TBD</typeparam>
        /// <typeparam name="TOut2">TBD</typeparam>
        /// <param name="first">TBD</param>
        /// <param name="second">TBD</param>
        /// <param name="strategy">TBD</param>
        /// <param name="rest">TBD</param>
        /// <returns>TBD</returns>
        public Source <TOut2, NotUsed> Combine <T, TOut2>(Source <T, NotUsed> first, Source <T, NotUsed> second, Func <int, IGraph <UniformFanInShape <T, TOut2>, NotUsed> > strategy, params Source <T, NotUsed>[] rest)
        => Source.FromGraph(GraphDsl.Create(b =>
        {
            var c = b.Add(strategy(rest.Length + 2));
            b.From(first).To(c.In(0));
            b.From(second).To(c.In(1));

            for (var i = 0; i < rest.Length; i++)
            {
                b.From(rest[i]).To(c.In(i + 2));
            }
            return(new SourceShape <TOut2>(c.Out));
        }));