Idiomatic way to use Spark DStream as Source for an Akka stream

后端 未结 2 754
再見小時候
再見小時候 2021-01-13 08:59

I\'m building a REST API that starts some calculation in a Spark cluster and responds with a chunked stream of the results. Given the Spark stream with calculation results,

2条回答
  •  遥遥无期
    2021-01-13 09:05

    Not sure about the version of api at the time of the question. But now, with akka-stream 2.0.3, I believe you can do it like:

    val source = Source
      .actorRef[T](/* buffer size */ 100, OverflowStrategy.dropHead)
      .mapMaterializedValue[Unit] { actorRef =>
        dstream.foreach(actorRef ! _)
      }
    

提交回复
热议问题