Got some time to experiment: with this definition

    val fetchLikesAndUpdateProfile = Flow[(OptProfile, 
LikesAndCount)].flatMapConcat 
{
      case (Some(profile), (likesExpected, stream)) ⇒ GraphDSL.create() {
        implicit builder ⇒
          import GraphDSL.Implicits._

          val in = builder.add(Source(stream))
          val profileLikesSink = builder.add(FileIO.toPath(new File(base, s
"likes_${profile.id}").toPath))
          in ~> Flow.fromFunction[Profile.Profile, ByteString](p ⇒ 
ByteString(s"${p.id}:${p.username}\n")) ~> profileLikesSink
          // update profile here with the numbers of records and emit i
          Source.single(profile).shape
      }
    }


The graph is teared at runtime:


java.lang.IllegalArgumentException: requirement failed: The inlets [] and 
outlets [single.out] must correspond to the inlets [] and outlets []
 at scala.Predef$.require(Predef.scala:219)
 at akka.stream.Shape.requireSamePortsAs(Shape.scala:168)
 at akka.stream.impl.StreamLayout$CompositeModule.replaceShape(StreamLayout.
scala:426)
 at akka.stream.scaladsl.GraphApply$class.create(GraphApply.scala:19)
 at akka.stream.scaladsl.GraphDSL$.create(Graph.scala:993)
 at sample.Aggregate$$anonfun$6.apply(Aggregate.scala:112)
 at sample.Aggregate$$anonfun$6.apply(Aggregate.scala:111)


Looks like it doesn't like *Source.single(profile).shape *but the type of 
the result should be *Graph[SourceShape[T],M]*, and I assume that the 
SourceShape should actually emit the updated profile object. Can somebody 
please explain how is it supposed to work, cuz I'm lost? 

Thanks!

-- 
>>>>>>>>>>      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+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to