public void RunnableGraphByGraphApiDoesntThrowEx() { IGraph <ClosedShape, NotUsed> gdsl = GraphDsl.Create(builder => { Source <int, NotUsed> source = Source.From(Enumerable.Range(1, 100)); var sink = Sink.Ignore <int>().MapMaterializedValue(_ => NotUsed.Instance); var broadcast = builder.Add(new Broadcast <int>(2)); var merge = builder.Add(new Merge <int>(2)); var f1 = Flow.Create <int>().Select(x => x + 10); var f2 = Flow.Create <int>().Select(x => x + 10); var f3 = Flow.Create <int>().Select(x => x + 10); var f4 = Flow.Create <int>().Select(x => x + 10); builder.From(source).Via(f1).Via(broadcast).Via(f2).Via(merge).Via(f3).To(sink); builder.From(broadcast).Via(f4).To(merge); return(ClosedShape.Instance); }); RunnableGraph <NotUsed> rg = RunnableGraph.FromGraph(gdsl); rg.Run(_materializer); }
public void BroadcastZipBalanceMerge() => _broadcastZipBalanceMerge.Run(_materializer).Ready();
public void BalanceMerge() => _balanceMerge.Run(_materializer).Ready();
public void BroadcastZip() => _broadcastZip.Run(_materializer).Ready();
public void RepeatTakeSelectAndAggregate() => _repeatTakeSelectAndAggregate.Run(_materializer).Ready();
public void ChainOfBuffers() => _chainOfBuffers.Run(_materializer).Ready();
public void SingleBuffer() => _singleBuffer.Run(_materializer).Ready();
public void ChainOfSelects() => _chainOfSelects.Run(_materializer).Ready();
public void SingleSelect() => _singleSelect.Run(_materializer).Ready();
public void ChainOfIdentities() => _chainOfIdentities.Run(_materializer).Ready();
public void SingleIdentity() => _singleIdentity.Run(_materializer).Ready();
public async Task RunnableGraphMadeOfBackpressuredQueueAndActorRefWithAckWorksAsExpected() { const int MAX = 4; Source <int, ISourceQueueWithComplete <int> > source = Source.Queue <int>(MAX, OverflowStrategy.Backpressure); TestProbe probe = CreateTestProbe(); Sink <IEnumerable <int>, NotUsed> sink = Sink.ActorRefWithAck <IEnumerable <int> >(probe.Ref, "init", "ack", "complete"); RunnableGraph <ISourceQueueWithComplete <int> > rg = RunnableGraph.FromGraph(GraphDsl.Create(source, sink, Keep.Left, (builder, source_, sink_) => { UniformFanOutShape <int, int> broadcaster = builder.Add(new Broadcast <int>(2)); UniformFanInShape <IEnumerable <int>, IEnumerable <int> > merger = builder.Add(new Merge <IEnumerable <int> >(2)); var f1 = Flow.Create <int>().Aggregate(new List <int>(), (agg, curr) => { agg.Add(curr); return(agg); }).Select(list => list.AsEnumerable()); var f2 = Flow.Create <int>().Aggregate(new List <int>(), (agg, curr) => { agg.Add(curr); return(agg); }).Select(list => list.AsEnumerable()); builder.From(source_).To(broadcaster.In); builder.From(broadcaster.Out(0)).Via(f1).To(merger.In(0)); builder.From(broadcaster.Out(1)).Via(f2).To(merger.In(1)); builder.From(merger.Out).To(sink_); return(ClosedShape.Instance); })); ISourceQueueWithComplete <int> q = rg.Run(_materializer); probe.ExpectMsg <string>((msg, sender) => { if (msg != "init") { throw new InvalidOperationException($"Expected: init. Found: {msg}"); } sender.Tell("ack"); }); await q.OfferAsync(2); await q.OfferAsync(4); await q.OfferAsync(8); await q.OfferAsync(16); q.Complete(); await q.WatchCompletionAsync(); probe.ExpectMsg <IEnumerable <int> >((msg, sender) => { Assert.Equal(new[] { 2, 4, 8, 16 }.AsEnumerable(), msg); sender.Tell("ack"); }); probe.ExpectMsg <IEnumerable <int> >((msg, sender) => { Assert.Equal(new[] { 2, 4, 8, 16 }.AsEnumerable(), msg); sender.Tell("ack"); }); probe.ExpectMsg("complete"); probe.ExpectNoMsg(); }