akka-stream

Accessing the underlying ActorRef of an akka stream Source created by Source.actorRef

一个人想着一个人 提交于 2019-11-27 04:13:35
I'm trying to use the Source.actorRef method to create an akka.stream.scaladsl.Source object. Something of the form import akka.stream.OverflowStrategy.fail import akka.stream.scaladsl.Source case class Weather(zip : String, temp : Double, raining : Boolean) val weatherSource = Source.actorRef[Weather](Int.MaxValue, fail) val sunnySource = weatherSource.filter(!_.raining) ... My question is: how do I send data to my ActorRef based Source object ? I assumed sending messages to the Source was something of the form //does not compile weatherSource ! Weather("90210", 72.0, false) weatherSource !

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

为君一笑 提交于 2019-11-26 23:59:19
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! 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 = 100 //if the buffer fills up then this strategy drops the oldest elements //upon the arrival of a new element.

Akka-Stream implementation slower than single threaded implementation

我怕爱的太早我们不能终老 提交于 2019-11-26 16:44:56
问题 UPDATE FROM 2015-10-30 based on Roland Kuhn Awnser: Akka Streams is using asynchronous message passing between Actors to implement stream processing stages. Passing data across an asynchronous boundary has an overhead that you are seeing here: your computation seems to take only about 160ns (derived from the single-threaded measurement) while the streaming solution takes roughly 1µs per element, which is dominated by the message passing. Another misconception is that saying “stream” implies

Accessing the underlying ActorRef of an akka stream Source created by Source.actorRef

我怕爱的太早我们不能终老 提交于 2019-11-26 12:43:06
问题 I\'m trying to use the Source.actorRef method to create an akka.stream.scaladsl.Source object. Something of the form import akka.stream.OverflowStrategy.fail import akka.stream.scaladsl.Source case class Weather(zip : String, temp : Double, raining : Boolean) val weatherSource = Source.actorRef[Weather](Int.MaxValue, fail) val sunnySource = weatherSource.filter(!_.raining) ... My question is: how do I send data to my ActorRef based Source object ? I assumed sending messages to the Source was

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 =