At the moment I have got this approach. Let's define a stage:
class OnFinish[A] extends GraphStage[FlowShape[A, A]] {
def onUpFinish: Unit = {}
def onDownFinish: Unit = {}
val in = Inlet[A]("onFinish.in")
val out = Outlet[A]("onFinish.out")
override val shape = FlowShape.of(in, out)
override def createLogic(attr: Attributes): GraphStageLogic = new
GraphStageLogic(shape) {
setHandler(in, new InHandler {
override def onPush(): Unit = push(out, grab(in))
override def onUpstreamFinish(): Unit = {
complete(out)
onUpFinish
}
})
setHandler(out, new OutHandler {
override def onPull(): Unit = pull(in)
override def onDownstreamFinish(): Unit = {
complete(out)
onDownFinish
}
})
}
}
Now, let's use it for source:
private lazy val flow = Flow.fromGraph(new OnFinish[ByteString] {
override def onUpFinish: Unit = cleanup
})
private lazy val finalSrc = src.via(flow)
At the use case in hands I have got what I wanted. But is this approach
correct in general?
--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.