Bad example in documentation

48 views
Skip to first unread message

Sergey Sopin

unread,
Jul 1, 2016, 6:31:03 PM7/1/16
to Akka User List
Hi,

It seems that one of examples in the documentation contains bug, namely: http://doc.akka.io/docs/akka/2.4.7/java/stream/stream-graphs.html

  1. final Source<Integer, NotUsed> in = Source.from(Arrays.asList(1, 2, 3, 4, 5));
  2. final Sink<List<String>, CompletionStage<List<String>>> sink = Sink.head();
  3. final Sink<List<Integer>, CompletionStage<List<Integer>>> sink2 = Sink.head();
  4. final Flow<Integer, Integer, NotUsed> f1 = Flow.of(Integer.class).map(elem -> elem + 10);
  5. final Flow<Integer, Integer, NotUsed> f2 = Flow.of(Integer.class).map(elem -> elem + 20);
  6. final Flow<Integer, String, NotUsed> f3 = Flow.of(Integer.class).map(elem -> elem.toString());
  7. final Flow<Integer, Integer, NotUsed> f4 = Flow.of(Integer.class).map(elem -> elem + 30);
  8. final RunnableGraph<CompletionStage<List<String>>> result =
  9.  RunnableGraph.<CompletionStage<List<String>>>fromGraph(
  10.    GraphDSL
  11.      .create(
  12.        sink,
  13.        (builder, out) -> {
  14.          final UniformFanOutShape<Integer, Integer> bcast = builder.add(Broadcast.create(2));
  15.          final UniformFanInShape<Integer, Integer> merge = builder.add(Merge.create(2));
  16.           final Outlet<Integer> source = builder.add(in).out();
  17.          builder.from(source).via(builder.add(f1))
  18.            .viaFanOut(bcast).via(builder.add(f2)).viaFanIn(merge)
  19.            .via(builder.add(f3.grouped(1000))).to(out);
  20.          builder.from(bcast).via(builder.add(f4)).toFanIn(merge);
  21.          return ClosedShape.getInstance();
  22.        }));

Here we define 'sink2' variable, but never use it. We are using 'out' variable instead, which is undefined.
Please fix this confusing thing when it will be possible.

Thanks,
Sergey

Patrik Nordwall

unread,
Jul 5, 2016, 6:06:23 AM7/5/16
to akka...@googlegroups.com
Thanks for reporting. Could you please open a pull request with the fix?
Regards,
Patrik

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--

Patrik Nordwall
Akka Tech Lead
Lightbend -  Reactive apps on the JVM
Twitter: @patriknw

Akka Team

unread,
Jul 5, 2016, 9:04:43 AM7/5/16
to Akka User List
Thanks for reporting, made the ticket: https://github.com/akka/akka/issues/20885
Would be awesome if you could submit a pull request to fix this mistake, thanks in advance!

Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam
Reply all
Reply to author
Forward
0 new messages