Hi Akka community,
I'm looking to confirm that the below strategy for managing back pressure
in sub-flows is sane.
I have a need to create a sub-flow within a custom stage. In order to
create the sub-flow, I'm using `prefixAndTail` as follows:
val (queue, source) =
Source
.queue[ByteString](100, OverflowStrategy.backpressure)
.prefixAndTail(0)
.map {
case (_, in) => in
}
.toMat(Sink.head)(Keep.both)
.run
This then provides me with a means to feed my custom stage's pushed input
into the sub-flow via a queue and source respectively:
queue.offer(bytes).andThen {
// Note that we're calling pull and cancel from a different thread.
// This is fine though given that the stage's onPush will not be called
// again until we pull or cancel.
case Success(QueueOfferResult.Enqueued) => pull(in)
case _ => cancel(in)
}
Thus I only wish to pull for more elements when backpressure permits.
Thanks for any confirmation or otherwise.
Kind regards,
Christopher
--
>>>>>>>>>> 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.