Replace LazyFlow with FutureFlow (#28729)

And implement other lazy flows on top of it

Co-Authored-By: Johannes Rudolph <johannes.rudolph@gmail.com>
This commit is contained in:
eyal farago 2020-05-14 11:28:53 +03:00 committed by GitHub
parent 9a1d5191b9
commit de59bb6803
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1435 additions and 739 deletions

View file

@ -27,7 +27,11 @@ import akka.util.OptionVal
override def initialAttributes: Attributes = DefaultAttributes.flatMapPrefix
override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Future[M]) = {
val matPromise = Promise[M]()
val propagateToNestedMaterialization =
inheritedAttributes
.mandatoryAttribute[Attributes.NestedMaterializationCancellationPolicy]
.propagateToNestedMaterialization
val matPromise = Promise[M]
val logic = new GraphStageLogic(shape) with InHandler with OutHandler {
val accumulated = collection.mutable.Buffer.empty[In]
@ -90,7 +94,10 @@ import akka.util.OptionVal
override def onDownstreamFinish(cause: Throwable): Unit = {
subSink match {
case OptionVal.None => downstreamCause = OptionVal.Some(cause)
case OptionVal.None if propagateToNestedMaterialization => downstreamCause = OptionVal.Some(cause)
case OptionVal.None =>
matPromise.failure(new NeverMaterializedException(cause))
cancelStage(cause)
case OptionVal.Some(s) => s.cancel(cause)
}
}