Hi,
I'm using Akka Stream M5. I have always been a fan of delayed/lazy
execution, kind of like Akka Stream's source->flow->sink and then run(). So
I created an array to store functions called:
val actionStream: ArrayBuffer[(IntermediateResult) => IntermediateResult] =
ArrayBuffer.empty[(IntermediateResult) => IntermediateResult]
Then I want to use Akka Stream's mapAsync to execute those stored
functions on data, so I wrote this:
protected val source: Source[NormalRow, Unit] = Source(() => data.
dataIterator)
val printSink = Sink.foreach[IntermediateResult](e => save(combine(e._1, e.
_2)))
val sourceReady = if (actionStream.size == 1)
source
.via(Flow[NormalRow]
.mapAsync(e => {println("inside here"); applyHeadFlow(e, actionStream.head
)}))
else
actionStream.drop(1).foldLeft(source
.via(Flow[NormalRow]
.mapAsync(e =>applyHeadFlow(e, actionStream.head)))
){(source, action) =>
source.via(Flow[IntermediateResult].mapAsync(e => Future(action(e))))
}
sourceReady.runWith(printSink)
And as you might notice, there is a discrepancy between the first
action and the subsequent actions (the first works on NormalRow, but the
rest works on IntermediateResult), so I created a helper function:
def applyHeadFlow(row: NormalRow, action: (IntermediateResult) =>
IntermediateResult): Future[IntermediateResult] = Future {
action.apply(row, None)
}
I thought this is already and should be fine, but when I tried to
run it, there is no output generated. So I start putting "println()"
statements inside the mapAsync() or Sink function, but console did not
print anything as well.
Can anyone care to offer somehelp??
Sincerely,
Allen
--
>>>>>>>>>> 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.