Need suggestion, I need to run parallel multiple source graphs, for example I have created this sample code where I am creating 10 graphs and running them parallel.
Is this right approach or should I create multiple source inside a graph and run them parallel in one graph?
def createGraph(start: Int, end: Int, name: String) = {
RunnableGraph.fromGraph(GraphDSL.create() {
implicit builder =>
import GraphDSL.Implicits._
val s = Source(start to end)
val f = Flow[Int].map[String](x => x.toString)
val sink = Sink.foreach[String](x => println(name + ":" + x))
val t = builder.add(s)
val flow1 = builder.add(f)
t ~> flow1 ~> sink
ClosedShape
})
}
(1 to 10).map(x => createGraph(x, x + 10, "g" + x)).map(_.run())
Thanks Arun