Removed not used UntypedPropsBehavior (#25054)
Removed unnecessary pattern matching
This commit is contained in:
parent
e8a955cdef
commit
1b83e339f4
6 changed files with 16 additions and 86 deletions
|
|
@ -11,7 +11,6 @@ import akka.actor.InvalidMessageException
|
|||
import akka.actor.typed.scaladsl.Behaviors
|
||||
import akka.{ Done, NotUsed, actor ⇒ untyped }
|
||||
import akka.testkit._
|
||||
import akka.actor.typed.Behavior.UntypedPropsBehavior
|
||||
|
||||
object AdapterSpec {
|
||||
val untyped1: untyped.Props = untyped.Props(new Untyped1)
|
||||
|
|
@ -297,27 +296,5 @@ class AdapterSpec extends AkkaSpec {
|
|||
typedRef ! "stop-child"
|
||||
probe.expectMsg("terminated")
|
||||
}
|
||||
|
||||
"spawn untyped behavior anonymously" in {
|
||||
val probe = TestProbe()
|
||||
val untypedBehavior: Behavior[String] = new UntypedPropsBehavior[String] {
|
||||
override def untypedProps(props: akka.actor.typed.Props): akka.actor.Props =
|
||||
untypedForwarder(probe.ref)
|
||||
}
|
||||
val ref = system.spawnAnonymous(untypedBehavior)
|
||||
ref ! "hello"
|
||||
probe.expectMsg("hello")
|
||||
}
|
||||
|
||||
"spawn untyped behavior" in {
|
||||
val probe = TestProbe()
|
||||
val untypedBehavior: Behavior[String] = new UntypedPropsBehavior[String] {
|
||||
override def untypedProps(props: akka.actor.typed.Props): akka.actor.Props =
|
||||
untypedForwarder(probe.ref)
|
||||
}
|
||||
val ref = system.spawn(untypedBehavior, "test")
|
||||
ref ! "hello"
|
||||
probe.expectMsg("hello")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,16 +178,6 @@ object Behavior {
|
|||
override def toString = "Unhandled"
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
* Used to create untyped props from behaviours, or directly returning an untyped props that implements this behavior.
|
||||
*/
|
||||
@InternalApi
|
||||
private[akka] abstract class UntypedPropsBehavior[T] extends Behavior[T] {
|
||||
/** INTERNAL API */
|
||||
@InternalApi private[akka] def untypedProps(props: Props): akka.actor.Props
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
|
|
@ -328,9 +318,6 @@ object Behavior {
|
|||
case null ⇒ throw new InvalidMessageException("[null] is not an allowed behavior")
|
||||
case SameBehavior | UnhandledBehavior ⇒
|
||||
throw new IllegalArgumentException(s"cannot execute with [$behavior] as behavior")
|
||||
case _: UntypedPropsBehavior[_] ⇒
|
||||
throw new IllegalArgumentException(s"cannot wrap behavior [$behavior] in " +
|
||||
"Behaviors.setup, Behaviors.supervise or similar")
|
||||
case d: DeferredBehavior[_] ⇒ throw new IllegalArgumentException(s"deferred [$d] should not be passed to interpreter")
|
||||
case IgnoreBehavior ⇒ SameBehavior.asInstanceOf[Behavior[T]]
|
||||
case s: StoppedBehavior[T] ⇒ s
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ package internal
|
|||
package adapter
|
||||
|
||||
import akka.actor.ExtendedActorSystem
|
||||
import akka.actor.typed.Behavior.UntypedPropsBehavior
|
||||
import akka.annotation.InternalApi
|
||||
import akka.util.OptionVal
|
||||
import akka.{ ConfigurationException, actor ⇒ a }
|
||||
|
|
@ -124,36 +123,22 @@ import scala.concurrent.duration._
|
|||
}
|
||||
|
||||
def spawnAnonymous[T](ctx: akka.actor.ActorContext, behavior: Behavior[T], props: Props): ActorRef[T] = {
|
||||
behavior match {
|
||||
case b: UntypedPropsBehavior[_] ⇒
|
||||
// TODO dispatcher from props
|
||||
ActorRefAdapter(ctx.actorOf(b.untypedProps(props)))
|
||||
|
||||
case _ ⇒
|
||||
try {
|
||||
Behavior.validateAsInitial(behavior)
|
||||
ActorRefAdapter(ctx.actorOf(PropsAdapter(() ⇒ behavior, props)))
|
||||
} catch {
|
||||
case ex: ConfigurationException if ex.getMessage.startsWith("configuration requested remote deployment") ⇒
|
||||
throw new ConfigurationException("Remote deployment not allowed for typed actors", ex)
|
||||
}
|
||||
try {
|
||||
Behavior.validateAsInitial(behavior)
|
||||
ActorRefAdapter(ctx.actorOf(PropsAdapter(() ⇒ behavior, props)))
|
||||
} catch {
|
||||
case ex: ConfigurationException if ex.getMessage.startsWith("configuration requested remote deployment") ⇒
|
||||
throw new ConfigurationException("Remote deployment not allowed for typed actors", ex)
|
||||
}
|
||||
}
|
||||
|
||||
def spawn[T](ctx: akka.actor.ActorContext, behavior: Behavior[T], name: String, props: Props): ActorRef[T] = {
|
||||
behavior match {
|
||||
case b: UntypedPropsBehavior[_] ⇒
|
||||
// TODO dispatcher from props
|
||||
ActorRefAdapter(ctx.actorOf(b.untypedProps(props), name))
|
||||
|
||||
case _ ⇒
|
||||
try {
|
||||
Behavior.validateAsInitial(behavior)
|
||||
ActorRefAdapter(ctx.actorOf(PropsAdapter(() ⇒ behavior, props), name))
|
||||
} catch {
|
||||
case ex: ConfigurationException if ex.getMessage.startsWith("configuration requested remote deployment") ⇒
|
||||
throw new ConfigurationException("Remote deployment not allowed for typed actors", ex)
|
||||
}
|
||||
try {
|
||||
Behavior.validateAsInitial(behavior)
|
||||
ActorRefAdapter(ctx.actorOf(PropsAdapter(() ⇒ behavior, props), name))
|
||||
} catch {
|
||||
case ex: ConfigurationException if ex.getMessage.startsWith("configuration requested remote deployment") ⇒
|
||||
throw new ConfigurationException("Remote deployment not allowed for typed actors", ex)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
package akka.actor.typed
|
||||
package scaladsl
|
||||
|
||||
import akka.actor.typed.Behavior.UntypedPropsBehavior
|
||||
import akka.actor.typed.internal.adapter._
|
||||
|
||||
/**
|
||||
|
|
@ -38,21 +37,11 @@ package object adapter {
|
|||
implicit class UntypedActorSystemOps(val sys: akka.actor.ActorSystem) extends AnyVal {
|
||||
|
||||
def spawnAnonymous[T](behavior: Behavior[T], props: Props = Props.empty): ActorRef[T] = {
|
||||
behavior match {
|
||||
case b: UntypedPropsBehavior[_] ⇒
|
||||
ActorRefAdapter(sys.actorOf(b.untypedProps(props)))
|
||||
case _ ⇒
|
||||
ActorRefAdapter(sys.actorOf(PropsAdapter(Behavior.validateAsInitial(behavior), props)))
|
||||
}
|
||||
ActorRefAdapter(sys.actorOf(PropsAdapter(Behavior.validateAsInitial(behavior), props)))
|
||||
}
|
||||
|
||||
def spawn[T](behavior: Behavior[T], name: String, props: Props = Props.empty): ActorRef[T] = {
|
||||
behavior match {
|
||||
case b: UntypedPropsBehavior[_] ⇒
|
||||
ActorRefAdapter(sys.actorOf(b.untypedProps(props), name))
|
||||
case _ ⇒
|
||||
ActorRefAdapter(sys.actorOf(PropsAdapter(Behavior.validateAsInitial(behavior), props), name))
|
||||
}
|
||||
ActorRefAdapter(sys.actorOf(PropsAdapter(Behavior.validateAsInitial(behavior), props), name))
|
||||
}
|
||||
|
||||
def toTyped: ActorSystem[Nothing] = AdapterExtension(sys).adapter
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import akka.actor.{ InternalActorRef, Scheduler }
|
|||
import akka.actor.typed.ActorRef
|
||||
import akka.actor.typed.ActorSystem
|
||||
import akka.actor.typed.Behavior
|
||||
import akka.actor.typed.Behavior.UntypedPropsBehavior
|
||||
import akka.actor.typed.Props
|
||||
import akka.actor.typed.internal.adapter.ActorRefAdapter
|
||||
import akka.actor.typed.internal.adapter.ActorSystemAdapter
|
||||
|
|
@ -142,10 +141,7 @@ import akka.japi.function.{ Function ⇒ JFunction }
|
|||
log.info("Starting Shard Region [{}]...", typeKey.name)
|
||||
|
||||
val untypedEntityPropsFactory: String ⇒ akka.actor.Props = { entityId ⇒
|
||||
behavior(entityId) match {
|
||||
case u: UntypedPropsBehavior[_] ⇒ u.untypedProps(Props.empty) // PersistentBehavior
|
||||
case b ⇒ PropsAdapter(b, entityProps)
|
||||
}
|
||||
PropsAdapter(behavior(entityId), entityProps)
|
||||
}
|
||||
|
||||
untypedSharding.internalStart(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import java.util.function.{ Function ⇒ JFunction }
|
|||
import akka.actor.{ ExtendedActorSystem, InvalidActorNameException }
|
||||
import akka.annotation.InternalApi
|
||||
import akka.cluster.singleton.{ ClusterSingletonProxy, ClusterSingletonManager ⇒ OldSingletonManager }
|
||||
import akka.actor.typed.Behavior.UntypedPropsBehavior
|
||||
import akka.cluster.typed.{ Cluster, ClusterSingleton, ClusterSingletonImpl, ClusterSingletonSettings }
|
||||
import akka.actor.typed.internal.adapter.ActorSystemAdapter
|
||||
import akka.actor.typed.{ ActorRef, ActorSystem, Behavior, Props }
|
||||
|
|
@ -41,10 +40,7 @@ private[akka] final class AdaptedClusterSingletonImpl(system: ActorSystem[_]) ex
|
|||
if (settings.shouldRunManager(cluster)) {
|
||||
val managerName = managerNameFor(singletonName)
|
||||
// start singleton on this node
|
||||
val untypedProps = behavior match {
|
||||
case u: UntypedPropsBehavior[_] ⇒ u.untypedProps(props) // PersistentBehavior
|
||||
case _ ⇒ PropsAdapter(behavior, props)
|
||||
}
|
||||
val untypedProps = PropsAdapter(behavior, props)
|
||||
try {
|
||||
untypedSystem.systemActorOf(
|
||||
OldSingletonManager.props(untypedProps, terminationMessage, settings.toManagerSettings(singletonName)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue