Continuing on with refactoring this into a better example, I came up with
the following graph:
val retrieveFromCacheOrUrl: Graph[FlowShape[String, Option[Content]], Unit
] = FlowGraph.partial() { implicit b =>
import FlowGraph.Implicits._
val cacheBroadcast = b.add(Broadcast[String](2))
val zip = b.add(Zip[String, Option[Content]]())
cacheBroadcast ~> zip.in0
cacheBroadcast ~> fetchCache ~> zip.in1
val filterBroadcast = b.add(Broadcast[(String, Option[Content])](2))
val cacheHitFilter = b.add(Flow[(String, Option[Content])].filter(_._2.
isDefined).map(_._2))
val cacheMissFilter = b.add(Flow[(String, Option[Content])].filter(_._2.
isEmpty).map(_._1))
val merge = b.add(Merge[Option[Content]](2))
zip.out ~> filterBroadcast
filterBroadcast ~> cacheHitFilter ~> merge
filterBroadcast ~> cacheMissFilter ~> fetchUrl ~> merge
FlowShape(cacheBroadcast.in, merge.out)
}
--
>>>>>>>>>> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.