Here is a more appropriately named version of the FlexiRoute subclass:
class OptionShape[A, B](_init: Init[(A, B)] = Name[(A, B)]("Option"))
extends FanOutShape[(A, B)](_init) {
val none = newOutlet[A]("optionNone")
val some = newOutlet[B]("optionSome")
protected override def construct(i: Init[(A, B)]) = new OptionShape(i)
}
class OptionRoute[A, B] extends FlexiRoute[(A, Option[B]), OptionShape[A,
Option[B]]](
new OptionShape, Attributes.name("Option")) {
import FlexiRoute._
override def createRouteLogic(p: PortT) = new RouteLogic[(A, Option[B])] {
override def initialState =
State[Any](DemandFromAll(p.none, p.some)) {
(ctx, _, element) =>
val (a, b) = element
b match {
case Some(i) => ctx.emit(p.some)(b)
case None => ctx.emit(p.none)(a)
}
SameState
}
override def initialCompletionHandling = eagerClose
}
}
--
>>>>>>>>>> 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.