akka-http

How to create a Source that can receive elements later via a method call?

て烟熏妆下的殇ゞ 提交于 2019-11-26 08:50:28
问题 I would like to create a Source and later push elements on it, like in: val src = ... // create the Source here // and then, do something like this pushElement(x1, src) pushElement(x2, src) What is the recommended way to do this? Thanks! 回答1: There are three ways this can be achieved: 1. Post Materialization with SourceQueue You can use Source.queue that materializes the Flow into a SourceQueue : case class Weather(zipCode : String, temperature : Double, raining : Boolean) val bufferSize =