include initialAttributes of GraphStage, #22463

* these must also be included via setAttributes because
  because it will create island for async (dispatcher attribute)
* better actor name of GraphStageIsland, we need it in tests for
  lookup of the actor
* this unlocks OutputStreamSourceSpec and InputStreamSinkSpec
This commit is contained in:
Patrik Nordwall 2017-03-07 19:40:50 +01:00
parent d5e117bfc9
commit 1a74b43cd6
8 changed files with 49 additions and 31 deletions

View file

@ -24,6 +24,9 @@ import org.reactivestreams.{ Processor, Publisher, Subscriber, Subscription }
import scala.collection.immutable.Map
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.ExecutionContextExecutor
import scala.annotation.tailrec
import akka.stream.impl.fusing.GraphInterpreter.DownstreamBoundaryStageLogic
import akka.stream.impl.fusing.GraphInterpreter.UpstreamBoundaryStageLogic
object PhasedFusingActorMaterializer {
@ -656,11 +659,23 @@ final class GraphStageIsland(
case _
val props = ActorGraphInterpreter.props(shell)
.withDispatcher(effectiveSettings.dispatcher)
materializer.actorOf(props, islandName)
materializer.actorOf(props, fullIslandName)
}
}
private def fullIslandName: String = {
@tailrec def findUsefulName(i: Int): String = {
if (i == logics.size) islandName
else logics.get(i) match {
case _: DownstreamBoundaryStageLogic[_] | _: UpstreamBoundaryStageLogic[_]
findUsefulName(i + 1)
case _
islandName + "-" + logics.get(i).attributes.nameOrDefault()
}
}
findUsefulName(0)
}
override def toString: String = "GraphStagePhase"
}
@ -714,8 +729,8 @@ final class SinkModulePhase(materializer: PhasedFusingActorMaterializer, islandN
override def takePublisher(slot: Int, publisher: Publisher[Any]): Unit = {
subscriberOrVirtualPublisher match {
case v: VirtualPublisher[Any] v.registerPublisher(publisher)
case s: Subscriber[Any] publisher.subscribe(s)
case v: VirtualPublisher[_] v.registerPublisher(publisher)
case s: Subscriber[Any] @unchecked publisher.subscribe(s)
}
}