Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't ask defined directly on ActorRef for Akka?

Tags:

scala

akka

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?

like image 251
Thayne Avatar asked Jan 02 '14 03:01

Thayne


1 Answers

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.

like image 173
Rob Napier Avatar answered Oct 20 '22 20:10

Rob Napier