It turns out not to be an issue with concat and futures... I believe the
issue is in relation to my usage of BroadcastHub (which I didn't reveal
before). Here's a reproducer:
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{ BroadcastHub, Keep, Source }
import scala.concurrent.duration._
import scala.concurrent.Promise
import scala.concurrent.ExecutionContext.Implicits.global
implicit val system = ActorSystem("test")
implicit val mat = ActorMaterializer()
val someSource =
Source.single("This is someSource")
.toMat(BroadcastHub.sink)(Keep.right)
.run()
val somePromise = Promise[String]
someSource.concat(Source.fromFuture(somePromise.future)).runForeach(println)
Thread.sleep(1000)
somePromise.success("This is some Promise")
The above outputs just the "This is some Promise", and not the "This
is someSource". I'm presuming that this is because the BroadcastHub
completes given the Source.single and so any subsequent usage
of someSource will represent that the source is completed. While this makes
sense and is as per the API spec, I was expecting that any buffered
elements of the broadcast sink would be flushed out first... seems not so
though.
My goal with the above code is to get hold of an output stream and source
without dealing with a future. Any further ideas on an approach would be
welcomed.
Thanks.
Cheers,
-C
--
>>>>>>>>>> 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.