Skip to content

Instantly share code, notes, and snippets.

@aludwiko
Created November 17, 2017 12:16
Show Gist options
  • Save aludwiko/8a60bc77ff5c23d62ed4f53c80687422 to your computer and use it in GitHub Desktop.
Save aludwiko/8a60bc77ff5c23d62ed4f53c80687422 to your computer and use it in GitHub Desktop.
val nonLinearFlow = Flow.fromGraph(GraphDSL.create() { implicit builder =>
 import GraphDSL.Implicits._
val dangerousFlow = Flow[Int].map {
  case 5 => throw new RuntimeException(“BOOM!”)
  case x => x
 }
 val safeFlow = Flow[Int]
 val bcast = builder.add(Broadcast[Int](2))
 val zip = builder.add(Zip[Int, Int])
bcast ~> dangerousFlow ~> zip.in0
 bcast ~> safeFlow ~> zip.in1
FlowShape(bcast.in, zip.out)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment