* DSL ActorContext extends typed ActorContext #24823 * remove unnecessary casts for ActorContext
This commit is contained in:
parent
6baa2b676e
commit
eac0467407
7 changed files with 15 additions and 13 deletions
|
|
@ -70,6 +70,13 @@ abstract class ActorContextSpec extends ActorTestKit with TypedAkkaSpecWithShutd
|
|||
|
||||
"An ActorContext" must {
|
||||
|
||||
"be usable from Behavior.interpretMessage" in {
|
||||
// compilation only
|
||||
lazy val b: Behavior[String] = Behaviors.receive { (ctx, msg) ⇒
|
||||
Behavior.interpretMessage(b, ctx, msg)
|
||||
}
|
||||
}
|
||||
|
||||
"canonicalize behaviors" in {
|
||||
val probe = TestProbe[Event]()
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,9 @@ import scala.reflect.ClassTag
|
|||
|
||||
def widened[T, U](behavior: Behavior[T], matcher: PartialFunction[U, T]): Behavior[U] = {
|
||||
behavior match {
|
||||
case d: DeferredBehavior[T] ⇒
|
||||
case d: DeferredBehavior[t] ⇒
|
||||
DeferredBehavior[U] { ctx ⇒
|
||||
val c = ctx.asInstanceOf[akka.actor.typed.ActorContext[T]]
|
||||
val b = Behavior.validateAsInitial(Behavior.start(d, c))
|
||||
val b = Behavior.validateAsInitial(Behavior.start(d, ctx.as[t]))
|
||||
Widened(b, matcher)
|
||||
}
|
||||
case _ ⇒
|
||||
|
|
@ -129,8 +128,7 @@ import scala.reflect.ClassTag
|
|||
behavior match {
|
||||
case d: DeferredBehavior[T] ⇒
|
||||
DeferredBehavior[T] { ctx ⇒
|
||||
val c = ctx.asInstanceOf[akka.actor.typed.ActorContext[T]]
|
||||
val b = Behavior.validateAsInitial(Behavior.start(d, c))
|
||||
val b = Behavior.validateAsInitial(Behavior.start(d, ctx))
|
||||
Intercept(beforeMessage, beforeSignal, afterMessage, afterSignal, b, toStringPrefix)
|
||||
}
|
||||
case _ ⇒
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import scala.util.control.NonFatal
|
|||
@InternalApi private[akka] object Supervisor {
|
||||
def apply[T, Thr <: Throwable: ClassTag](initialBehavior: Behavior[T], strategy: SupervisorStrategy): Behavior[T] =
|
||||
Behaviors.setup[T] { ctx ⇒
|
||||
val c = ctx.asInstanceOf[akka.actor.typed.ActorContext[T]]
|
||||
val supervisor: Supervisor[T, Thr] = strategy match {
|
||||
case Restart(-1, _, loggingEnabled) ⇒
|
||||
new Restarter(initialBehavior, initialBehavior, loggingEnabled)
|
||||
|
|
@ -42,7 +41,7 @@ import scala.util.control.NonFatal
|
|||
.asInstanceOf[Supervisor[T, Thr]]
|
||||
}
|
||||
|
||||
supervisor.init(c)
|
||||
supervisor.init(ctx)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,13 +95,12 @@ import akka.util.ConstantFun
|
|||
override def unstashAll(ctx: javadsl.ActorContext[T], behavior: Behavior[T]): Behavior[T] =
|
||||
unstashAll(ctx.asScala, behavior)
|
||||
|
||||
override def unstash(scaladslCtx: scaladsl.ActorContext[T], behavior: Behavior[T],
|
||||
override def unstash(ctx: scaladsl.ActorContext[T], behavior: Behavior[T],
|
||||
numberOfMessages: Int, wrap: T ⇒ T): Behavior[T] = {
|
||||
val iter = new Iterator[T] {
|
||||
override def hasNext: Boolean = StashBufferImpl.this.nonEmpty
|
||||
override def next(): T = wrap(StashBufferImpl.this.dropHead())
|
||||
}.take(numberOfMessages)
|
||||
val ctx = scaladslCtx.asInstanceOf[ActorContext[T]]
|
||||
Behavior.interpretMessages[T](behavior, ctx, iter)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ import akka.annotation.InternalApi
|
|||
behavior match {
|
||||
case d: DeferredBehavior[T] ⇒
|
||||
DeferredBehavior[T] { ctx ⇒
|
||||
val c = ctx.asInstanceOf[akka.actor.typed.ActorContext[T]]
|
||||
val started = Behavior.validateAsInitial(Behavior.start(d, c))
|
||||
val started = Behavior.validateAsInitial(Behavior.start(d, ctx))
|
||||
chooseOutermostOrWrap(staticMdc, mdcForMessage, started)
|
||||
}
|
||||
case b ⇒
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import scala.concurrent.ExecutionContextExecutor
|
|||
*/
|
||||
@DoNotInherit
|
||||
@ApiMayChange
|
||||
trait ActorContext[T] {
|
||||
trait ActorContext[T] extends akka.actor.typed.ActorContext[T] {
|
||||
// this must be a pure interface, i.e. only abstract methods
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import akka.annotation.InternalApi
|
|||
*/
|
||||
@DoNotInherit
|
||||
@ApiMayChange
|
||||
trait ActorContext[T] { this: akka.actor.typed.javadsl.ActorContext[T] ⇒
|
||||
trait ActorContext[T] extends akka.actor.typed.ActorContext[T] { this: akka.actor.typed.javadsl.ActorContext[T] ⇒
|
||||
|
||||
/**
|
||||
* Get the `javadsl` of this `ActorContext`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue