private static Flow <TIn, TOut, NotUsed> Balancer <TIn, TOut>(Flow <TIn, TOut, NotUsed> worker, int workerCount)
        {
            return(Flow.FromGraph(GraphDsl.Create(b =>
            {
                var balancer = b.Add(new Balance <TIn>(workerCount, waitForAllDownstreams: true));
                var merge = b.Add(new Merge <TOut>(workerCount));

                for (var i = 0; i < workerCount; i++)
                {
                    b.From(balancer).Via(worker.Async()).To(merge);
                }

                return new FlowShape <TIn, TOut>(balancer.In, merge.Out);
            })));
        }