I am playing with Akka Streams and streaming content from a file using Alpakka. I need to stop the stream after some time so I want to use KillSwitc
h. But I don't know how to use it because I am using the graph DSL.
My graph looks like this:
val graph = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: GraphDSL.Builder[NotUsed] =>
import GraphDSL.Implicits._
source ~> mainFlow ~> sink
ClosedShape
})
graph.run()
I found a solution here: How to abruptly stop an akka stream Runnable Graph?
However, I don't know how to apply it if I'm using the graph DSL. Can you give me some advice?