Class AskPattern.Askable$
- java.lang.Object
-
- akka.actor.typed.scaladsl.AskPattern.Askable$
-
- Enclosing class:
- AskPattern
public static class AskPattern.Askable$ extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static AskPattern.Askable$
MODULE$
Static reference to the singleton instance of this Scala object.
-
Constructor Summary
Constructors Constructor Description Askable$()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <U,T>
scala.concurrent.Future<U>$qmark$extension(AskPattern.Askable<T> $this, scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
The ask-pattern implements the initiator side of a request–reply protocol.<U,T>
scala.concurrent.Future<U>ask$extension(AskPattern.Askable<T> $this, scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
The ask-pattern implements the initiator side of a request–reply protocol.<T> boolean
equals$extension(AskPattern.Askable<T> $this, java.lang.Object x$1)
<T> int
hashCode$extension(AskPattern.Askable<T> $this)
-
-
-
Field Detail
-
MODULE$
public static final AskPattern.Askable$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
$qmark$extension
public final <U,T> scala.concurrent.Future<U> $qmark$extension(AskPattern.Askable<T> $this, scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
The ask-pattern implements the initiator side of a request–reply protocol. The?
operator is pronounced as "ask" (and a convenience symbolic operation kept since the previous ask API, if unsure which one to use, prefer the non-symbolic method as it leads to fewer surprises with the scope of thereplyTo
function)Note that if you are inside of an actor you should prefer
ActorContext.ask
as that provides better safety.The party that asks may be within or without an Actor, since the implementation will fabricate a (hidden)
ActorRef
that is bound to aPromise
. This ActorRef will need to be injected in the message that is sent to the target Actor in order to function as a reply-to address, therefore the argument to the ask /?
operator is not the message itself but a function that given the reply-to address will create the message.case class Request(msg: String, replyTo: ActorRef[Reply]) case class Reply(msg: String) implicit val scheduler = system.scheduler implicit val timeout = Timeout(3.seconds) val target: ActorRef[Request] = ... val f: Future[Reply] = target ? (replyTo => (Request("hello", replyTo)))
Note: it is preferrable to use the non-symbolic ask method as it easier allows for wildcards for the
ActorRef
.- Parameters:
$this
- (undocumented)replyTo
- (undocumented)timeout
- (undocumented)scheduler
- (undocumented)- Returns:
- (undocumented)
-
ask$extension
public final <U,T> scala.concurrent.Future<U> ask$extension(AskPattern.Askable<T> $this, scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
The ask-pattern implements the initiator side of a request–reply protocol.Note that if you are inside of an actor you should prefer
ActorContext.ask
as that provides better safety.The party that asks may be within or without an Actor, since the implementation will fabricate a (hidden)
ActorRef
that is bound to aPromise
. This ActorRef will need to be injected in the message that is sent to the target Actor in order to function as a reply-to address, therefore the argument to the ask /?
operator is not the message itself but a function that given the reply-to address will create the message.case class Request(msg: String, replyTo: ActorRef[Reply]) case class Reply(msg: String) implicit val scheduler = system.scheduler implicit val timeout = Timeout(3.seconds) val target: ActorRef[Request] = ... val f: Future[Reply] = target.ask(replyTo => (Request("hello", replyTo))) // alternatively val f2: Future[Reply] = target.ask(Request("hello", _)) // note that the explicit type on f2 is important for the compiler // to understand the type of the wildcard
- Parameters:
$this
- (undocumented)replyTo
- (undocumented)timeout
- (undocumented)scheduler
- (undocumented)- Returns:
- (undocumented)
-
hashCode$extension
public final <T> int hashCode$extension(AskPattern.Askable<T> $this)
-
equals$extension
public final <T> boolean equals$extension(AskPattern.Askable<T> $this, java.lang.Object x$1)
-
-