Package akka.actor.typed.scaladsl
Class AskPattern.Askable<T>
- java.lang.Object
-
- scala.AnyVal
-
- akka.actor.typed.scaladsl.AskPattern.Askable<T>
-
- Enclosing class:
- AskPattern
public static final class AskPattern.Askable<T> extends scala.AnyVal
-
-
Constructor Summary
Constructors Constructor Description Askable(RecipientRef<T> ref)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <U> scala.concurrent.Future<U>
$qmark(scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
<U> scala.concurrent.Future<U>
ask(scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
The ask-pattern implements the initiator side of a request–reply protocol.boolean
equals(java.lang.Object x$1)
int
hashCode()
RecipientRef<T>
ref()
-
-
-
Constructor Detail
-
Askable
public Askable(RecipientRef<T> ref)
-
-
Method Detail
-
ref
public RecipientRef<T> ref()
-
$qmark
public <U> scala.concurrent.Future<U> $qmark(scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
-
ask
public <U> scala.concurrent.Future<U> ask(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:
replyTo
- (undocumented)timeout
- (undocumented)scheduler
- (undocumented)- Returns:
- (undocumented)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x$1)
- Overrides:
equals
in classjava.lang.Object
-
-