이것은 GraphDSL API를 사용하는 정말 간단하고 초보적인 질문입니다. 나는 여러 스레드 SO 관련 읽고 난 대답을 볼 수 없습니다 :Akka Streams : GraphDSL API에서 Materialized Sink 출력을 얻으려면 어떻게해야합니까?
val actorSystem = ActorSystem("QuickStart")
val executor = actorSystem.dispatcher
val materializer = ActorMaterializer()(actorSystem)
val source: Source[Int, NotUsed] = Source(1 to 5)
val throttledSource = source.throttle(1, 1.second, 1, ThrottleMode.shaping)
val intDoublerFlow = Flow.fromFunction[Int, Int](i => i * 2)
val sink = Sink.foreach(println)
val graphModel = GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._
throttledSource ~> intDoublerFlow ~> sink
// I presume I want to change this shape to something else
// but I can't figure out what it is.
ClosedShape
}
// TODO: This is RunnableGraph[NotUsed], I want RunnableGraph[Future[Done]] that gives the
// materialized Future[Done] from the sink. I presume I need to use a GraphDSL SourceShape
// but I can't get that working.
val graph = RunnableGraph.fromGraph(graphModel)
// This works and gives me the materialized sink output using the simpler API.
// But I want to use the GraphDSL so that I can add branches or junctures.
val graphThatIWantFromDslAPI = throttledSource.toMat(sink)(Keep.right)
내가 도와 준 문서 참조를 위해 upvoted ;-) –
ahh 결승선에 맞음;) 잘 연주 –
당신 덕분에. GraphDSL.create (sink) 호출에 싱크를 추가하면 ClosedShape에 컴파일러 오류가 발생합니다. 어떻게 업데이트합니까? – clay