*TL;DR -- Is there any way to provide an individual Flow component with
logic to execute on Graph completion?*
I'm trying to wrap an existing API that is used like this:
obj.handleContext(c1)
obj.handleState(s1)
obj.handleState(s2)
obj.handleState(sN)
obj.concludeContext(c1)
.. in a flow, very much like this:
def toFlow(handler: Handler) = {
var ctxt: Option[Context] = None
Flow[(Context, State)].map {
(in: (Context, State)) => {
ctxt match {
case Some(last) => if (!last.equals(in._1)) {
last.concludeContext()
ctxt = Some(in._1)
}
case None => ctxt = Some(in._1)
}
handler.handleState(in._2)
handler.concludeState(in._2)
in
}
}
}
I then combine the various handlers created using this method together
using ~> and use .grouped() and Sink.head to collect the resulting values.
*I need to call handler.concludeContext() on the last context passed in to
the flow on completion for each sub-flow.*
My backup plan it to wrap the flow components in another class that holds
the context and manually calling the conclude method on them en masse once
the flow completes, but would much prefer to use some built in mechanism
instead if there were one.
I'm also open to other strategies that may help me avoid being stateful,
but to date haven't thought of any.
(I'm using akka-actor 2.4.0 and akka-streams-experiental 1.0)
Thanks,
Rich
--
>>>>>>>>>> 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.