This solve my problem, but seems strange:
object SpeedViolation {
var state: Option[Double] = None
def apply(maxSpeed: Double) = {
state = Some(maxSpeed)
Flow[(CarStatus, Option[Double])].map((params) => {
val (carStatus, speed) = params
state = speed orElse state
carStatus.speed > state.get
})
}
}
The flow input is a tuple, the element I want process and a Option
parameter. What do you think?
On Monday, July 27, 2015 at 9:24:34 AM UTC-3, Matheus Lima wrote:
>
> How can I create a dynamic flow? I'm developing a stream processing
> application and I have a specific stage that I need perform a calculation
> over input considering a parameter. And I need change this parameter
> dynamically. For example:
> case class CarStatus(position: Position, speed: Double)
> Flow[CarStatus].map(_.speed > 80)
> How can I transform 80 in a dynamic parameter?
> Thank you.
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.