From 64fa8f5ccd9cdf56c617dc45cb1de0c3f01a5dee Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Thu, 6 Sep 2018 09:52:25 +0200 Subject: [PATCH] Remove Scheduler param in EntityRef.ask, #25481 --- .../typed/internal/ClusterShardingImpl.scala | 13 +++++++------ .../sharding/typed/javadsl/ClusterSharding.scala | 4 +--- .../sharding/typed/scaladsl/ClusterSharding.scala | 10 +++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ClusterShardingImpl.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ClusterShardingImpl.scala index 1c0171a7ea..7f230f753c 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ClusterShardingImpl.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ClusterShardingImpl.scala @@ -189,11 +189,11 @@ import akka.japi.function.{ Function ⇒ JFunction } } 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] = { - new EntityRefImpl[A](untypedSharding.shardRegion(typeKey.name), entityId) + new EntityRefImpl[A](untypedSharding.shardRegion(typeKey.name), entityId, system.scheduler) } override def defaultShardAllocationStrategy(settings: ClusterShardingSettings): ShardAllocationStrategy = { @@ -207,13 +207,14 @@ import akka.japi.function.{ Function ⇒ JFunction } /** * 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] { override def tell(msg: A): Unit = 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 m = message(replyTo.ref) if (replyTo.promiseRef ne null) replyTo.promiseRef.messageClassName = m.getClass.getName @@ -221,8 +222,8 @@ import akka.japi.function.{ Function ⇒ JFunction } replyTo.future } - def ask[U](message: JFunction[ActorRef[U], A], timeout: Timeout, scheduler: Scheduler): CompletionStage[U] = - ask[U](replyTo ⇒ message.apply(replyTo))(timeout, scheduler).toJava + def ask[U](message: JFunction[ActorRef[U], A], timeout: Timeout): CompletionStage[U] = + ask[U](replyTo ⇒ message.apply(replyTo))(timeout).toJava /** Similar to [[akka.actor.typed.scaladsl.AskPattern.PromiseRef]] but for an `EntityRef` target. */ @InternalApi diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala index 7b0a458867..43a23d2f6e 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ClusterSharding.scala @@ -260,10 +260,8 @@ object EntityTypeKey { /** * Allows to "ask" the [[EntityRef]] for a reply. * 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 diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala index f91c84f983..1dbcd984f9 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ClusterSharding.scala @@ -291,9 +291,9 @@ object EntityTypeKey { * 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. @@ -309,10 +309,10 @@ object EntityTypeKey { * 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] = - this.ask(message)(timeout, scheduler) + def ?[U](message: ActorRef[U] ⇒ A)(implicit timeout: Timeout): Future[U] = + this.ask(message)(timeout) }