+str #18142 ask pattern integration for akka streams
progressed with cleanup, removing the same thread exec context is weird... causes issues :-/ Need to debug more, could be that some race also exists in mapAsync then :\ WIP finish ask impl via watch stage mima consistency spec fix paradox, and fix adding ask/watch to javadsl source follow up review
This commit is contained in:
parent
5040ce82f1
commit
4714f16dcf
18 changed files with 643 additions and 47 deletions
|
|
@ -5,10 +5,12 @@ package akka.stream.impl.fusing
|
|||
|
||||
import java.util.concurrent.TimeUnit.NANOSECONDS
|
||||
|
||||
import akka.actor.{ ActorRef, Terminated }
|
||||
import akka.annotation.{ DoNotInherit, InternalApi }
|
||||
import akka.dispatch.ExecutionContexts
|
||||
import akka.event.Logging.LogLevel
|
||||
import akka.event.{ LogSource, Logging, LoggingAdapter }
|
||||
import akka.pattern.AskSupport
|
||||
import akka.stream.Attributes.{ InputBuffer, LogLevels }
|
||||
import akka.stream.OverflowStrategies._
|
||||
import akka.stream.impl.fusing.GraphStages.SimpleLinearGraphStage
|
||||
|
|
@ -27,7 +29,9 @@ import akka.stream.ActorAttributes.SupervisionStrategy
|
|||
|
||||
import scala.concurrent.duration.{ FiniteDuration, _ }
|
||||
import akka.stream.impl.Stages.DefaultAttributes
|
||||
import akka.util.OptionVal
|
||||
import akka.util.{ OptionVal, Timeout }
|
||||
|
||||
import scala.reflect.ClassTag
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
|
|
@ -1325,6 +1329,33 @@ private[stream] object Collect {
|
|||
}
|
||||
}
|
||||
|
||||
@InternalApi private[akka] final case class Watch[T](targetRef: ActorRef) extends SimpleLinearGraphStage[T] {
|
||||
|
||||
override def initialAttributes = DefaultAttributes.watch
|
||||
|
||||
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
|
||||
new GraphStageLogic(shape) with InHandler with OutHandler with StageLogging {
|
||||
|
||||
private lazy val self = getStageActor {
|
||||
case (_, Terminated(`targetRef`)) ⇒
|
||||
failStage(new WatchedActorTerminatedException("Watch", targetRef))
|
||||
}
|
||||
|
||||
override def preStart(): Unit = {
|
||||
// initialize self, and watch the target
|
||||
self.watch(targetRef)
|
||||
}
|
||||
|
||||
override def onPull(): Unit =
|
||||
pull(in)
|
||||
|
||||
override def onPush(): Unit =
|
||||
push(out, grab(in))
|
||||
|
||||
setHandlers(in, out, this)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue