Hi everyone,

we are currently integrating Akka-Streams in an application.

Looking at the current Flow DSL/API, I can see that Transformers 
(Flow#transform) allow to *synchronously* produce a number of 
output-messages from 1 message.
abstract class Transformer[-T, +U] {
*  /***
*   * Invoked for each element to produce a (possibly empty) sequence of*
*   * output elements.*
*   */*
  def onNext(element: T): *immutable.Seq[U]*
Semantically, the Flow remains a Flow[U] - not a Flow[Seq[U]] - despite 
multiplying the incoming message. (Great!)

Is there also a way to achieve the same thing *asynchronously *in a Flow 
(i.e. transform a single message into multiples)?
>From what I've seen, the FlowDSL supports mapFuture which allows async 
computation of a single output message:
*  /***
*   * Transform this stream by applying the given function to each of the 
elements*
*   * as they pass through this processing step. The function returns a 
`Future` of the*
*   * element that will be emitted downstream. As many futures as requested 
elements by*
*   * downstream may run in parallel and may complete in any order, but the 
elements that*
*   * are emitted downstream are in the same order as from upstream.*
*   */*
  def mapFuture[U](f: T ⇒ Future[U]): Flow[U]

Again, the Flow remains a Flow[U] - despite the async computation of the 
output element.
Naturally mapFuture follows the semantics of the map operation and converts 
1 input msg into 1 output message.

Using MapFuture to produce a Seq[U] would alter the Flow from Flow[U] to 
Flow[Seq[U]].
Following processors in that Flow would have to deal with Sequences instead 
of single messages.
This somewhat defies the purpose of backpressure.

Maybe I am missing another function of the Flow DSL, but I haven't found 
it...

Thanks for any help,
-Thomas

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to