I am learning about Akka, and while exploring the API, I came across something kind of curious (at least to me). The tell
function is defined directly on the ActorRef class. However, the ask
function is declared in the AskSupport trait. I can't think of any good reasons why they needed a seperate trait for AskSupport
rather than including ask
in the API for ActorRef (and ?
in the API of ScalaActorRef). Would anyone care to enlighten me on the reasoning behind this?
The Actor docs gives the author's reasoning:
The ask pattern involves actors as well as futures, hence it is offered as a use pattern rather than a method on ActorRef
The ask pattern includes Future extensions, not just ActorRef extensions. In particular, if you look through the akka.pattern docs, you'll note PipeToSupport
and PipeableFuture
beyond the extensions to Akka objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With