Merge pull request #25572 from akka/wip-25481-EntityRef-scheduler-patriknw

Remove Scheduler param in EntityRef.ask, #25481
This commit is contained in:
Patrik Nordwall 2018-09-18 19:48:59 +02:00 committed by GitHub
commit 82bcbb68d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 14 deletions

View file

@ -189,11 +189,11 @@ import akka.japi.function.{ Function ⇒ JFunction }
} }
override def entityRefFor[A](typeKey: scaladsl.EntityTypeKey[A], entityId: String): scaladsl.EntityRef[A] = { override def entityRefFor[A](typeKey: scaladsl.EntityTypeKey[A], entityId: String): scaladsl.EntityRef[A] = {
new EntityRefImpl[A](untypedSharding.shardRegion(typeKey.name), entityId) new EntityRefImpl[A](untypedSharding.shardRegion(typeKey.name), entityId, system.scheduler)
} }
override def entityRefFor[A](typeKey: javadsl.EntityTypeKey[A], entityId: String): javadsl.EntityRef[A] = { override def entityRefFor[A](typeKey: javadsl.EntityTypeKey[A], entityId: String): javadsl.EntityRef[A] = {
new EntityRefImpl[A](untypedSharding.shardRegion(typeKey.name), entityId) new EntityRefImpl[A](untypedSharding.shardRegion(typeKey.name), entityId, system.scheduler)
} }
override def defaultShardAllocationStrategy(settings: ClusterShardingSettings): ShardAllocationStrategy = { override def defaultShardAllocationStrategy(settings: ClusterShardingSettings): ShardAllocationStrategy = {
@ -207,13 +207,14 @@ import akka.japi.function.{ Function ⇒ JFunction }
/** /**
* INTERNAL API * INTERNAL API
*/ */
@InternalApi private[akka] final class EntityRefImpl[A](shardRegion: akka.actor.ActorRef, entityId: String) @InternalApi private[akka] final class EntityRefImpl[A](shardRegion: akka.actor.ActorRef, entityId: String,
scheduler: Scheduler)
extends javadsl.EntityRef[A] with scaladsl.EntityRef[A] { extends javadsl.EntityRef[A] with scaladsl.EntityRef[A] {
override def tell(msg: A): Unit = override def tell(msg: A): Unit =
shardRegion ! ShardingEnvelope(entityId, msg) shardRegion ! ShardingEnvelope(entityId, msg)
override def ask[U](message: (ActorRef[U]) A)(implicit timeout: Timeout, scheduler: Scheduler): Future[U] = { override def ask[U](message: (ActorRef[U]) A)(implicit timeout: Timeout): Future[U] = {
val replyTo = new EntityPromiseRef[U](shardRegion.asInstanceOf[InternalActorRef], timeout) val replyTo = new EntityPromiseRef[U](shardRegion.asInstanceOf[InternalActorRef], timeout)
val m = message(replyTo.ref) val m = message(replyTo.ref)
if (replyTo.promiseRef ne null) replyTo.promiseRef.messageClassName = m.getClass.getName if (replyTo.promiseRef ne null) replyTo.promiseRef.messageClassName = m.getClass.getName
@ -221,8 +222,8 @@ import akka.japi.function.{ Function ⇒ JFunction }
replyTo.future replyTo.future
} }
def ask[U](message: JFunction[ActorRef[U], A], timeout: Timeout, scheduler: Scheduler): CompletionStage[U] = def ask[U](message: JFunction[ActorRef[U], A], timeout: Timeout): CompletionStage[U] =
ask[U](replyTo message.apply(replyTo))(timeout, scheduler).toJava ask[U](replyTo message.apply(replyTo))(timeout).toJava
/** Similar to [[akka.actor.typed.scaladsl.AskPattern.PromiseRef]] but for an `EntityRef` target. */ /** Similar to [[akka.actor.typed.scaladsl.AskPattern.PromiseRef]] but for an `EntityRef` target. */
@InternalApi @InternalApi

View file

@ -260,10 +260,8 @@ object EntityTypeKey {
/** /**
* Allows to "ask" the [[EntityRef]] for a reply. * Allows to "ask" the [[EntityRef]] for a reply.
* See [[akka.actor.typed.javadsl.AskPattern]] for a complete write-up of this pattern * See [[akka.actor.typed.javadsl.AskPattern]] for a complete write-up of this pattern
*
* Please note that a [[akka.util.Timeout]] and [[akka.actor.Scheduler]] must be available to use this pattern.
*/ */
def ask[U](message: JFunction[ActorRef[U], A], timeout: Timeout, scheduler: Scheduler): CompletionStage[U] def ask[U](message: JFunction[ActorRef[U], A], timeout: Timeout): CompletionStage[U]
/** /**
* INTERNAL API * INTERNAL API

View file

@ -291,9 +291,9 @@ object EntityTypeKey {
* val f: Future[Reply] = target.ask(Request("hello", _)) * val f: Future[Reply] = target.ask(Request("hello", _))
* }}} * }}}
* *
* Please note that an implicit [[akka.util.Timeout]] and [[akka.actor.Scheduler]] must be available to use this pattern. * Please note that an implicit [[akka.util.Timeout]] must be available to use this pattern.
*/ */
def ask[U](f: ActorRef[U] A)(implicit timeout: Timeout, scheduler: Scheduler): Future[U] def ask[U](f: ActorRef[U] A)(implicit timeout: Timeout): Future[U]
/** /**
* Allows to "ask" the [[EntityRef]] for a reply. * Allows to "ask" the [[EntityRef]] for a reply.
@ -309,10 +309,10 @@ object EntityTypeKey {
* val f: Future[Reply] = target ? (Request("hello", _)) * val f: Future[Reply] = target ? (Request("hello", _))
* }}} * }}}
* *
* Please note that an implicit [[akka.util.Timeout]] and [[akka.actor.Scheduler]] must be available to use this pattern. * Please note that an implicit [[akka.util.Timeout]] must be available to use this pattern.
*/ */
def ?[U](message: ActorRef[U] A)(implicit timeout: Timeout, scheduler: Scheduler): Future[U] = def ?[U](message: ActorRef[U] A)(implicit timeout: Timeout): Future[U] =
this.ask(message)(timeout, scheduler) this.ask(message)(timeout)
} }